UISplitViewControllerDelegate - willHideViewController:...不发送 UIBarButtonItem?
我已经实现了 UISplitViewControllerDelegate,我试图找出为什么我的代码在旋转时崩溃。
现在,我将 AppDelegate 作为实现委托方法的对象,然后为详细视图设置了一个协议 (SubstitutableDetailViewController
),以处理 UIBarButton 项的添加/删除。
- (void)splitViewController:(UISplitViewController*)svc
willHideViewController:(UIViewController *)aViewController
withBarButtonItem:(UIBarButtonItem*)barButtonItem
forPopoverController:(UIPopoverController*)pc {
// Keep references to the popover controller and the popover button, and tell the detail view controller to show the button.
NSLog(@"barButtonItem class %@",[barButtonItem class]);
[barButtonItem setTitle:[NSString stringWithString:@"Menu"]];
self.popoverController = pc;
self.rootPopoverButtonItem = barButtonItem;
UIViewController <SubstitutableDetailViewController> *detailViewController = [splitViewController.viewControllers objectAtIndex:1];
[detailViewController showRootPopoverButtonItem:rootPopoverButtonItem];
}
这里的问题是日志打印出“barButtonItem class __NSCFArray”。
为什么 UIBarButtonItem 会作为数组出现?然后,这会引发错误,因为我正在尝试设置“数组”的标题。
-[__NSCFArray view]: unrecognized selector sent to instance 0x150510
关于为什么它不是正确的对象有什么想法吗?
如果我将它们注释掉,当我尝试将此 barButtonItem 添加到工具栏时,它会引发错误。再次强调,它不是对象的写入类型。
I've implemented the UISplitViewControllerDelegate and I'm trying to find why my code crashes when I rotate.
Right now I have my AppDelegate as the object that implements the delegate methods and then I have a protocol (SubstitutableDetailViewController
) setup for my details views to handle the adding/removing of the UIBarButton item.
- (void)splitViewController:(UISplitViewController*)svc
willHideViewController:(UIViewController *)aViewController
withBarButtonItem:(UIBarButtonItem*)barButtonItem
forPopoverController:(UIPopoverController*)pc {
// Keep references to the popover controller and the popover button, and tell the detail view controller to show the button.
NSLog(@"barButtonItem class %@",[barButtonItem class]);
[barButtonItem setTitle:[NSString stringWithString:@"Menu"]];
self.popoverController = pc;
self.rootPopoverButtonItem = barButtonItem;
UIViewController <SubstitutableDetailViewController> *detailViewController = [splitViewController.viewControllers objectAtIndex:1];
[detailViewController showRootPopoverButtonItem:rootPopoverButtonItem];
}
The issue here is that the log prints out 'barButtonItem class __NSCFArray'.
Why would the UIBarButtonItem be coming through as an array? This then throws an error because I'm trying to set the title of the "array".
-[__NSCFArray view]: unrecognized selector sent to instance 0x150510
Any ideas as to why it wouldn't be the right object?
And if I comment them out, it throws an error when I try to add this barButtonItem to the toolbar. Again, it isn't the write type of object.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论