• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

iOS:我不确定,但我的委托(delegate)没有按我的计划工作

[复制链接]
菜鸟教程小白 发表于 2022-12-13 05:37:40 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我有一个没有按计划工作的委托(delegate),我有这样的设置。我想调用函数 NSLog(show); 我不太清楚为什么这不起作用,但可以与我的其他 View Controller 一起使用。我一定是遗漏了一些小细节。

AccountViewController.h

@protocol AccountViewControllerDelegate;
@interface AccountViewController : UIViewController{

}
@property (nonatomic, assign) id <AccountViewControllerDelegate> accountViewDelegate;
@end

@protocol AccountViewControllerDelegate <NSObject>
- (void)showLabel;
@end

AccountViewController.m

-(IBAction)saveid)sender {
    [self showLabel];
}

- (void)showLabel {
    if (self.accountViewDelegate) {
        NSLog(@"showlabel");

        [self.accountViewDelegate showLabel];
    }
}

MapViewController.m

-(void)showLabel {
    NSLog(@"SHOW");
}



Best Answer-推荐答案


您尚未显示将 MapViewController 分配为 AccountViewController 的委托(delegate)的位置。也许这就是你所缺少的

//(from somewhere in the MapViewController)

AccountViewController *accountVC = //however you instantiate it (segue, storyboard etc
accountVC.accountViewDelegate = self;

关于iOS:我不确定,但我的委托(delegate)没有按我的计划工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20569331/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap