私はiPhone用のアプリを書いています。正常に動作しますが、iPad では正しくスケーリングされません。私は横向きのビューを持っており、プログラムでそれを行いました。それから私はプッシュをしています。次に、これを示します。

回転してフルスクリーンにしたい。私を助けてください。前もって感謝します。
私はiPhone用のアプリを書いています。正常に動作しますが、iPad では正しくスケーリングされません。私は横向きのビューを持っており、プログラムでそれを行いました。それから私はプッシュをしています。次に、これを示します。
回転してフルスクリーンにしたい。私を助けてください。前もって感謝します。
次のコードのようにios6またはios5でオリエンテーションを確認して実装できます。情報は各クラスにメソッドを配置します。
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
ViewWillApear
そして、次のようなデバイスの向きで毎回チェックしてください:-
- (void)willRotateToOrientation:(UIInterfaceOrientation)newOrientation {
if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation))
{
if (newOrientation == UIInterfaceOrientationLandscapeLeft || newOrientation == UIInterfaceOrientationLandscapeRight) {
//set your landscap View Frame
[self supportedInterfaceOrientations];
}
}
else if (UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation))
{
if(newOrientation == UIInterfaceOrientationPortrait || newOrientation == UIInterfaceOrientationPortraitUpsideDown){
//set your Potrait View Frame
[self supportedInterfaceOrientations];
}
}
// Handle rotation
}
-(void)viewWillAppear:(BOOL)animated
{
[self willRotateToOrientation:[[UIDevice currentDevice] orientation]];
[super viewWillAppear:YES];
}
アップデート
おそらく人々は、この行を:-orientation
に入れる際に、以下のようなチェックデバイスを使用しますViewWillApear
[[UIApplication sharedApplication] statusBarOrientation];
[[UIDevice currentDevice] orientation];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceRotated:) name:UIDeviceOrientationDidChangeNotification object:nil];
と
-(void)deviceRotated:(NSNotification*)notification
{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
//Do your stuff for landscap
}
else if(orientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
//Do your stuff for potrait
}
}
IOS5 では、次のように実行できるランドスケープのみ:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
return YES;
}
else
{
return NO;
}
}
すべてのオリエンテーションをサポートしたい場合は、次のように YES を返す必要があります:-
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}