【问题标题】:Orientation Issues in ios 6.0ios 6.0 中的方向问题
【发布时间】:2023-03-12 02:55:01
【问题描述】:

我已经完成了 iPhone 和 iPad 的纵向应用程序,现在我需要横向的应用程序,iPhone 和 iPad 都只使用 xib。一些 UI 是以编程方式创建的。刚才我是使用这个代码:

-(NSUInteger)supportedInterfaceOrientations
{
    // return your mask here e.g.:
    if(UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation]))
        return UIInterfaceOrientationMaskPortrait;
    else
        return UIInterfaceOrientationMaskLandscape;
}

但它不能正常工作,所以任何人都可以帮助我......?

【问题讨论】:

标签: iphone objective-c ios6 uiinterfaceorientation device-orientation


【解决方案1】:

将此代码更改为以下内容:

-(NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;  
}

并添加以下内容:

- (BOOL) shouldAutorotate
{
    return YES;
}

【讨论】:

  • Thanq Sviatoslav,但是在这里我可以检查条件,例如 if (UIInterfaceOrientationMaskPortrait) else ....?因为我可能会调整 UI 的大小类似于方向。
【解决方案2】:

我终于做到了,现在正在使用这段代码;

-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 持续时间:(NSTimeInterval)duration { if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { // NSLog(@"横向左");

} else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
    NSLog(@"Landscape right");

} else if (toInterfaceOrientation == UIInterfaceOrientationPortrait) {
  //  NSLog(@"Portrait");

} else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
   // NSLog(@"Upside down");
}

} 它对所有方向都有好处,谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-18
    • 2012-09-06
    • 2013-02-09
    • 2012-12-30
    • 2013-10-14
    • 2015-11-03
    • 2013-11-17
    • 1970-01-01
    相关资源
    最近更新 更多