问题
我制作了一个UIViewController的子类,用于处理横向模式,然后我将子类划分为子类,并显示给用户。现在,我不想在横向视图中添加子类,并且大小与横向视图相同,但为了获得框架,我需要添加动作
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
我在第一个子类中也使用了它。然而,当我这样做时,它会忽略超类中的所有代码,并做一件事(获取帧)
我能做什么
- 我可以用一段代码获得横向框架,比如
[[UIScreen mainScreen].landscapeFrame
或类似的东西(如果存在的话) - 重写子类中超类的代码(但是,拥有超类有什么意义?)
更新/修复
愚蠢的我,我忘了添加[super didRotateFromInterfaceOrientation: fromInterfaceOrientation];
感谢Sanjay Chaudhry注意到了这一点,谢谢!:)
在覆盖的方法中调用Super的方法:
[super didRotateFromInterfaceOrientation: fromInterfaceOrientation];