
我在actionbar.m的vIEwDIDLoad中做了一些图形设置,比如backgroundcolor和其他一些东西.
我在这个actionbar上也有一个按钮,我通常用IBAction链接按钮的方式.
我将actionbar加载到我的主屏幕中,如下所示:
ActionbarWithlogoff *actionbar = [[ActionbarWithlogoff alloc] initWithNibname:@"ActionbarWithlogoff" bundle:nil];[topbar addSubvIEw:actionbar.vIEw];[actionbar release];
我的actionbar.h:
- (IBAction)Actionbarlogoff:(ID)sender;
我的actionbars.m的方法:
-(voID) Actionbarlogoff:(UIbutton *)sender{NSLog(@"!!!!!!!!!!Actionbarlogoff");} 这是我的错误钢铁图片,当我点击按钮我得到以下错误:
2014-01-27 13:52:21.856 GB_Mobil_DK[2954:60b] -[__NSArrayM
Actionbarlogoff:]: unrecognized selector sent to instance 0x1656d880
2014-01-27 13:52:21.858 GB_Mobil_DK[2954:60b] * Terminating app due
to uncaught exception ‘NSinvalidargumentexception’,reason:
‘-[__NSArrayM Actionbarlogoff:]: unrecognized selector sent to
instance 0x1656d880’
* First throw call stack: (0x2f94be83 0x39ca86c7 0x2f94f7b7 0x2f94e0af 0x2f89cdc8 0x32104da3 0x32104d3f 0x32104d13 0x320f0743
0x3210475b 0x32104425 0x320ff451 0x320d4d79 0x320d3569 0x2f916f1f
0x2f9163e7 0x2f914bd7 0x2f87f471 0x2f87f253 0x345b92eb 0x32134845
0x97985 0x3a1a1ab7) libc++abi.dylib: terminating with uncaught
exception of type NSException
有谁能告诉我为什么?最重要的是能够帮我解决这个问题^^?
解决方法 您正在释放actionbar实例并保留其视图.如果actionbar实例响应按钮 *** 作,则按钮单击消息将被发送到已删除的实例.您应该保留actionbar实例.一种方法是将其作为ivar或保留财产.看起来您正在为自定义视图创建UIVIEwController.相反,您可以使用其XIB创建自定义UIVIEw.
编辑
声明保留财产,
@property (nonatomic,retain) ActionbarWithlogoff *actionbar;
要么
简单地声明为ivar,
@interface YourVIEwController: UIVIEwController { ActionbarWithlogoff *actionbar;} 在dealloc方法中,
-(voID) dealloc { //... [actionbar release]; //...} 希望有所帮助!
总结以上是内存溢出为你收集整理的iOS,无法识别的选择器发送到实例?全部内容,希望文章能够帮你解决iOS,无法识别的选择器发送到实例?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)