- (IBAction)toggleMasterHidden:(id)sender
{
isMasterHidden = !isMasterHidden;
self.delegate = nil;
self.delegate = self;
[self.view setNeedsLayout];
}
- (BOOL)splitViewController:(UISplitViewController *)svc
shouldHideViewController:(UIViewController *)vc
inOrientation:(UIInterfaceOrientation)orientation
{
return isMasterHidden;
}
这工作正常,但结果是即时的。我正在尝试为过渡设置动画,但不确定我应该采取的方法。以下内容将不起作用,因为setNeedsLayout
实际上并没有改变视图,它只是设置了一个标志,说稍后再做。
// Does not work
[UIView beginAnimations:@"toggleMaster" context:nil];
[UIView setAnimationDuration:0.4];
[self.view setNeedsLayout];
[UIView commitAnimations];
// Also does not work, I'm assuming parent class implementation is empty
- (void)viewWillLayoutSubviews
{
[UIView beginAnimations:@"toggleMaster" context:nil];
[UIView setAnimationDuration:0.4];
[super viewWillLayoutSubviews];
[UIView commitAnimations];
}
恐怕我必须创建一个自定义的 splitviewcontroller 来实现这一点,这很遗憾,因为我认为这是一个接近完整的实现。