iphone - 单击导航UIBarButtonItem时收到EXC_BAD_ACCESS信号吗?

标签 iphone ios ipad

我有一个应用程序,正在尝试为聊天应用程序实现LibPusher API。

该API已启用arc,并且已将其包含在我的nonarc项目中。
除了一些警告,它工作正常。

现在我的问题是我在导航栏中添加了一个像这样的按钮:

UIButton *btnNext1 =[[UIButton alloc] init];
    [btnNext1 setBackgroundImage:[UIImage imageNamed:@"back_btn.png"] forState:UIControlStateNormal];

    btnNext1.frame = CGRectMake(100, 100,60, 31);
    UIBarButtonItem *btnNext =[[UIBarButtonItem alloc] initWithCustomView:btnNext1];
    [btnNext1 addTarget:self action:@selector(backButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = btnNext;
    [btnNext1 release];

一切正常,我正在这样做:
PusherPresenceEventsViewController *rootView = ( PusherPresenceEventsViewController*)[self.navigationController.viewControllers objectAtIndex:1];
rootView.newmessage =@"";
[self.navigationController popToViewController:rootView animated:YES];
[rootView release];

前两次也可以正常工作。
但是,第三次出现错误的访问错误。
我不明白我哪里出了问题,有人可以帮助我吗?

最佳答案

UIButton *btnNext1 =    [UIButton buttonWithType:UIButtonTypeCustom]

并不要释放它。也要释放Rootview,因为您没有分配它。

关于iphone - 单击导航UIBarButtonItem时收到EXC_BAD_ACCESS信号吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13012742/

相关文章:

iphone - Apple 是否允许监控跳板事件?

ios - 无法加载4S拍摄的图像,但可以加载5S

iphone - 将 iPad xib 转换为 iPhone xib

iphone - 将 UIImageView 从 UIScrollView 拖到另一个 View

iphone - CGAffineTransform Rotation 拉伸(stretch)了我的图像,我做错了什么?

ios - 以恒定中心减小 UIButton 大小

iphone - iPad SplitViewController 用法 - 在您已经拥有 Split View后不允许推送 SplitViewController 的设计理念是什么?

iphone - 如何将 appDelegate 绑定(bind)到应用程序的其余部分?

iphone - UISearchBar 和 resignFirstResponder

iphone - 如何获取CCSprite中特定像素的RGBA颜色