【发布时间】:2015-06-01 16:51:03
【问题描述】:
我是 SplitViewController 的新手,我遇到了以下问题。这是设置:
在 IB 中,我只有一个链接到 SVC 作为细节 VC 的 VC(这与标准的 Master Detail 项目模板相比,它有一个导航控制器作为细节层次结构的起点)。我这样做是为了尝试最大化细节 VC 中的图像空间。
然后,我将 UIToolbar(称为 imageTable)添加到详细信息 VC,并通过 IBoutlet 连接到详细信息 VC 类。
我正在使用详细信息 VC 作为 SVC 委托。
然后我在detail VC中采用以下SVC delegate 3方法:
#pragma mark - SplitViewController Delegates
-(BOOL) splitViewController:(UISplitViewController *)svc
shouldHideViewController:(UIViewController *)vc
inOrientation:(UIInterfaceOrientation)orientation
{
return UIInterfaceOrientationIsPortrait(orientation);
}
-(void) splitViewController:(UISplitViewController *)svc
willHideViewController:(UIViewController *)aViewController
withBarButtonItem:(UIBarButtonItem *)barButtonItem
forPopoverController:(UIPopoverController *)pc
{
barButtonItem.title=@"ImageList";
NSMutableArray *toolbarItems=[self.imageTable.items mutableCopy];
[toolbarItems insertObject:barButtonItem atIndex:0];
self.imageTable.items=toolbarItems;
}
-(void) splitViewController:(UISplitViewController *)svc
willShowViewController:(UIViewController *)aViewController
invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem
{
NSMutableArray *toolbarItems=[self.imageTable.items mutableCopy];
[toolbarItems removeObjectAtIndex:0];
self.imageTable.items=toolbarItems;
}
因为我没有在 VC 中使用 Nav Controller 作为起点,所以我遇到了以下问题:
当我转回横向时,UIToolBar 会自动消失。在 SVC 类中是否固有因为代表 VC 重新出现的 UIBarbuttonItem 在横向中不再需要,所以我创建的 UIToolbar 也是如此(强调“I”)...
是否有任何方法可以向 UIToolbar 添加或启用标题,或者是使用标签的唯一方法。
谢谢
【问题讨论】:
标签: ios xcode uisplitviewcontroller uibarbuttonitem uitoolbar