私は基本的にこのコードを実行しているよ返されません。 statusBarOrientationをNSLogにしようとすると、向きが何であっても1が返されます。iPadの向きが正しく
これは私のアプリデリゲート、ビューコントローラ、および私が必要とするクラスと同じことです。 info.plist/targetの設定では、4つのデバイス方向がすべてサポートされています。
誰かがインターフェイスの方向を把握するための確実な方法を持っているのですか、なぜ私が機能していないのですか?ありがとう
私は基本的にこのコードを実行しているよ返されません。 statusBarOrientationをNSLogにしようとすると、向きが何であっても1が返されます。iPadの向きが正しく
これは私のアプリデリゲート、ビューコントローラ、および私が必要とするクラスと同じことです。 info.plist/targetの設定では、4つのデバイス方向がすべてサポートされています。
誰かがインターフェイスの方向を把握するための確実な方法を持っているのですか、なぜ私が機能していないのですか?ありがとう
あなたが向きの変更の通知を登録することができます
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRotate:)
name:@"UIDeviceOrientationDidChangeNotification"
object:nil];
- (void)didRotate:(NSNotification *)notification
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if ((orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)) {
// DO STUFF
}
else if (orientation == UIDeviceOrientationPortrait) {
//DO MORE STUFF
}
}
現在、ステータスバーの方向を戻しています。代わりに、デバイスの向きを取得:[[UIDevice currentDevice] orientation]
そこにこんにちは、私はこのコードをしようとしているが、動作するようには思えません。 if(UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation))){NSLog(@ "私たちは風景です"); } ありがとう – user339946
あなたのviewControllerは、 'shouldAutorotateToInterfaceOrientation'のためにYESを返しますか? – Evan
あなたはオリエンテーションのための通知を使用したいといけない場合..その後、あまりにも法の下に使用します。
これが唯一のランドスケープのiPadでのオリエンテーションやiPhoneでのポートレートの例です...
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
if(interfaceOrientation==UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation==UIInterfaceOrientationLandscapeLeft)
return YES;
else
return NO;
}
else
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
}
ありがとうございます。何らかの理由で、このコードは実際にはビューの読み込みで機能します。これは非常に助けになります。ありがとう – user339946
問題ない、私は助けることができてうれしい。 –