我做了很多研究,UISplitView当Master和Detail的视图发生变化时,无法找到控制Split View的方法.
然后我找到了一种使用作为委托的单例类来管理它的方法.
我的问题是,我不确定这是否是正确的方法.我很关心reusability和memory managment.此外,我有一种感觉,这是苹果的指导方针,使单身人士成为代表.
这就是我所拥有的(它实际上是有效的):
// SharedSplitViewDelegate.h
/* In the detail view controllers:
// in the initial detail view controller
- (void)awakeFromNib
{
[super awakeFromNib];
// needs to be here, otherwise if it's booted in portrait the button is not set
self.splitViewController.delegate = [SharedSplitViewDelegate initSharedSplitViewDelegate];
}
// shared between all detail view controllers
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
SharedSplitViewDelegate *rotationHandler = [SharedSplitViewDelegate initSharedSplitViewDelegate];
[self.toolbar setItems:[rotationHandler processButtonArray:self.toolbar.items] animated:YES];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
*/ …Run Code Online (Sandbox Code Playgroud)