目前,我的整个应用程序处于纵向模式,并且仅限于此。我希望仅在点击一个按钮时启用横向,然后在点击另一个按钮时返回纵向。
我该怎么做?
谢谢
詹姆斯
最佳答案
在您的 View .m 文件中,您应该在底部看到一个函数:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
更改适当的方向以使其正确并在按钮中引用它。或者将 if then 复制并粘贴到按钮中。应该可以了。
关于iphone - 如何使用 UIButton 上的代码解锁横向模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7377333/