English 中文(简体)
iPad 服用
原标题:Get launch orientation of iPad app

在我看来,我需要实施一些布局法,根据方向确定适当的布局。 否则,布局就是为了景观取向,因此,如果图象始于 por形模式,我需要采取额外行动,妥善整理意见,以显示在孔隙。

在我的<条码>应用:didFinishLaunching WithOptions:方法中,我用<条码>对方向进行核对。 这里的问题是,即使人们从地貌开始,它总是会回到十字路口。 是否有办法解决这一问题?

最佳回答
问题回答

这是检查发射方向的最佳途径。 首先,在您的推荐人中创立一种新办法,检查方向:

-(void)checkLaunchOrientation:(id)sender{

     UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;    
     BOOL isLandscape = UIDeviceOrientationIsLandscape(self.viewController.interfaceOrientation);

     if (UIInterfaceOrientationIsLandscape(orientation) || isLandscape) {
       //do stuff here
     }
}

在<end of -application:didFinishLaunching WithOptions: 1 P-4, 1 P-3, 1 P-2

        [self performSelectorOnMainThread:@selector(checkLaunchOrientation:) withObject:nil waitUntilDone:NO];

如上所述,有一套测试导向的宏观。 然而,这一博客职位提到了UIDeviceOrientationIsPortrait。 我与下文一样,只字不提。

if(UIInterfaceOrientationIsPortrait(self.interfaceOrientation))
{
  NSLog(@"Portrait");
}
else
{
  NSLog(@"Landscape");
}

我提出的一个意见是,你可以把这部守则放在一张桌上,推向位于不同观点控制器中的导航主计长。 因此,换言之,你可以要求总的看法控制者提一下。 您必须替换“自称方向”,代之以分裂观点控制器。

而是利用地位限制取向来检测。

1. 概念外向导向=[共同应用方法]。

接着,如果你从上述来源获得“定位”。

因此,问题是在启动时检查方向。 可悲的是,答案是“你可以 t”。

<>>>>AFTERstartup, 您可检查方向的正常方向(如其他人所述)。

如果其他人来到这里寻求答案,那么就只是停止了眼光,因为,在开始的时候,方向变量并未确定(所有观点框架/约束都报告说,即便是 t的,也存在漏洞)。

你希望确保你在“信息清单”中确定适当的钥匙,使你能够了解:

UISupportedInterfaceOrientations
    UIInterfaceOrientationPortrait
    UIInterfaceOrientationPortraitUpsideDown
    UIInterfaceOrientationLandscapeLeft
    UIInterfaceOrientationLandscapeRight

你们不需要另一个答案,但我认为我应该补充一点,你们几乎永远都不想使用<条码>[`现有数字”取向]<>。 这种方法回收了该装置的方向,其方向与接口的方向必然相同。

不能说你可以 out出发射方向,确实在后方造成痛苦。

在这方面,你需要做些什么。

your first UIViewController needs to have some special logic to nab the information you d like.
you might even want to create a UIStartupController just for these purposes if it s that important to your flow.
in the case of my project, we already had such a startup controller present.

你们所需要的是以下法典:

-(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  if (self) {
    self.launchOrientation = UIDeviceOrientationUnknown;
  }
  return self;
}

-(void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
                                duration:(NSTimeInterval)duration
{
  [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

  if (self.launchOrientation == UIDeviceOrientationUnknown && duration > 0)
    self.launchOrientation = UIInterfaceOrientationPortrait;
  else
    self.launchOrientation = toInterfaceOrientation;
}

basically, if we re not launching in UIInterfaceOrientationPortrait, the first rotation callback sequence will actually reveal the launch orientation.
if launched in UIInterfaceOrientationPortrait, then we need to check that the first rotation s duration is non zero, and then we know that it was launched from portrait.





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签