在iOS8上,UISplitViewController改变,现在通知其通过挂起DISPLAYMODE变化的代表splitViewController:willChangeToDisplayMode:
我需要更新我的辅助视图控制器的某些方面在应对这种变化。
这是很简单的这种委托方法时呼吁二次VC的方法,但是VC还不知道它的新边界将是什么。
有没有被通知VC的边界将分开改变,从志愿次级VC的边界合理的方式? 理想情况下,VC将有viewWillTransitionToSize:withTransitionCoordinator:
呼吁DISPLAYMODE变化,因为它提供了动画旁边的过渡的能力。
所以,现在我只是用志愿。 我跟一些建议在这里 。
在viewDidLoad
:
[self.view addObserver:self
forKeyPath:NSStringFromSelector(@selector(frame))
options:(NSKeyValueObservingOptionOld|NSKeyValueObservingOptionNew)
context:nil];
然后:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([object isKindOfClass:[UIScrollView class]] && [keyPath isEqualToString:NSStringFromSelector(@selector(frame))]) {
CGRect newFrame = [change[@"new"] CGRectValue];
CGRect oldFrame = [change[@"old"] CGRectValue];
if ((newFrame.size.width == oldFrame.size.width) || (newFrame.size.height == oldFrame.size.height)) {
// If one dimension remained constant, we assume this is a displayMode change instead of a rotation
// Make whatever changes are required here, with access to new and old frame sizes.
}
}
}
我想这在视图的边界,但在框架上开了很多更经常比国际志愿者组织。
文章来源: How can I prepare a UISplitViewController secondary VC for a change to displayMode?