我正在尝试开发通用iOS应用程序,以便在纵向和横向模式下都能正常工作。但是我无法触发一个操作来加载我在设备中方向更改视图上的横向视图
答案 0 :(得分:1)
创建您的应用程序,然后在您的应用程序摘要中转到支持的界面方向并选择您要激活的应用程序:
然后,您可以使用以下两种方法之一:
如果操作在旋转之前,则从UIViewController覆盖:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
// do something before rotation
}
如果您想在轮换后执行某些操作:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
// do something after rotation
}