我做了一个iPad应用程序,
当我第一次以纵向模式加载应用程序时,它工作正常,但是当我第一次以横向模式加载应用程序时,它仅采用纵向模式的坐标,因为在我的内部didLoad
方法我只给出纵向模式的坐标。
现在需要给出我的横向模式的坐标didLoad
method.
我在 didLoad 方法中尝试过这个
if (interfaceOrientation == UIInterfacePortraitmode ||
interfaceOrientation == UIInterfaceUpsideDown)
{
// do this....
}
else
{
// do this....
}
但我无法在我的内部编写 if/else 的条件didLoad
method.
我应该怎么办?
您可以进行如下处理——
-(void) viewWillAppear: (BOOL) animated {
[super viewWillAppear: animated];
[self updateLayoutForNewOrientation: self.interfaceOrientation];
}
-(void) willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation duration: (NSTimeInterval) duration {
[self updateLayoutForNewOrientation: interfaceOrientation];
}
最后是自定义方法 -
- (void) updateLayoutForNewOrientation: (UIInterfaceOrientation) orientation {
if (UIInterfaceOrientationIsLandscape(orientation)) {
// Do some stuff
} else {
// Do some other stuff
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)