- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 UIViewController
,它的 View 属性中有几个 subview (UISearchbar
和几个 UIButton
)。 UIButton
连接到典型的 IBAction
,例如 -(IBAction)buttonPressed:(id)sender
for the UIControlEventTouchUpInside
状态 - 无论我是在 IB 中还是以编程方式执行都没有关系。
- (void)viewDidLoad {
MUZTitleViewController *title = [[MUZTitleViewController alloc]
initWithNibName:nil bundle:nil];
self.navigationItem.titleView = title.view;
}
在我的项目中还有一个UINavigationController
。当我将 UINavigationBar
的 navigationItem.titleView
设置为我的 UIViewController
View 时,我一点击就收到 EXC_BAD_ACCESS 异常其中一个按钮。我不知道这是为什么。
我上传了一个小示例项目来说明我的问题:Test010.xcodeproj (它启用了 ARC)
越来越多的我得出结论,使用 UIViewController
的 View 并将其分配给 titleView
不是一个好主意,但我没有看到任何在这里选择。
编辑: 抱歉,示例项目注释掉了导致异常的调用。我重新上传了链接的项目文件。
编辑^2:正如 PengOne 指出的那样,我已经跳过了我收到的确切错误消息:
2011-09-10 23:09:50.621 Test010[78639:f803] -[CALayer buttonPressed:]: unrecognized selector sent to instance 0x9254ae0
2011-09-10 23:09:50.623 Test010[78639:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CALayer buttonPressed:]: unrecognized selector sent to instance 0x9254ae0'
最佳答案
您是否尝试过将 NSZombieEnabled 设置为 YES?如果我这样做,控制台会显示以下输出:
2011-09-10 22:56:23.329 Test010[6481:ef03] *** -[MUZTitleViewController
performSelector:withObject:withObject:]: message sent to deallocated
instance 0x7a7ff70
由于项目启用了 ARC, Controller 似乎在这一行之后的某个时间被释放:
MUZTitleViewController *title = [[MUZTitleViewController alloc] initWithNibName:nil bundle:nil];
我不确定最好的解决方案是什么,但是属性肯定有助于防止这样的异常:
// MUZDetailViewController.h
@property (strong, nonatomic) MUZTitleViewController *title;
// MUZDetailViewController.m
@synthesize title;
self.title = [[MUZTitleViewController alloc] initWithNibName:nil bundle:nil];
self.navigationItem.titleView = title.view;
关于ios - 自定义 View 中的 Crasher 作为 UINavigationControllers navigationItem.titleView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7374629/
在学习 NSInvocations 时,我对内存管理的理解似乎存在差距。 这是一个示例项目: @interface DoNothing : NSObject @property (nonatomic,
我有一个 UIViewController,它的 View 属性中有几个 subview (UISearchbar 和几个 UIButton)。 UIButton 连接到典型的 IBAction,例如
我有一个崩溃问题,它在我们的生产应用程序中经常发生,但我们无法重现它。它仅发生在使用 iOS8 SDK 的 iOS8 上。 HTTPReadFilter::doPlainRead(StreamRead
我是一名优秀的程序员,十分优秀!