プッシュ通知が来ると、appdelegate クラスでカスタム UILabel を表示しています。ポートレート モードでは正常に動作していますが、デバイスをランドスケープ モードに回転すると、ラベルがポートレート モードのまま表示されます。どうすれば修正できますか。ローテーションメソッドを実装しました。しかし、うまくいきませんでした。前もって感謝します。
私のコードは次のとおりです。
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
CGRect frame=[[UIApplication sharedApplication] statusBarFrame];
if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft
|| [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight) {
backgroundImageView=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 480, 32)];
} else {
backgroundImageView=[[UILabel alloc] initWithFrame:CGRectMake(0, frame.size.height, 320, 44)];
NSLog(@"portrait");
}
[backgroundImageView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"alert.png"]]];
backgroundImageView.userInteractionEnabled=YES;
UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(click:)];
[backgroundImageView addGestureRecognizer:tgr];
[self.window addSubview:backgroundImageView];
}![enter image description here][1]