1
iPhoneの向きが横向きに変わったときにViewControllerを押すと、ViewControllerの向きを変更するときに問題が発生します。ViewController向きの変更
Iは、そのコードを使用する:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
Storage *strg = [Storage sharedStorage];
if ([strg.orient intValue] == 2)
{
[[UIApplication sharedApplication] setStatusBarOrientation:
UIInterfaceOrientationLandscapeRight];
UIScreen *screen = [UIScreen mainScreen];
CGFloat screenWidth = screen.bounds.size.width;
CGFloat screenHeight = screen.bounds.size.height;
UIView *navView = [[self navigationController] view];
navView.bounds = CGRectMake(0, 0, screenHeight, screenWidth);
navView.transform = CGAffineTransformIdentity;
navView.transform = CGAffineTransformMakeRotation(1.57079633);
navView.center = CGPointMake(screenWidth/2.0, screenHeight/2.0);
[UIView commitAnimations];
}
if ([strg.orient intValue] == 1)
{
[[UIApplication sharedApplication] setStatusBarOrientation:
UIInterfaceOrientationLandscapeLeft];
UIScreen *screen = [UIScreen mainScreen];
CGFloat screenWidth = screen.bounds.size.width;
CGFloat screenHeight = screen.bounds.size.height;
UIView *navView = [[self navigationController] view];
navView.bounds = CGRectMake(0, 0, screenHeight, screenWidth);
navView.transform = CGAffineTransformIdentity;
navView.transform = CGAffineTransformMakeRotation(4.71238898);
navView.center = CGPointMake(screenWidth/2.0, screenHeight/2.0);
[UIView commitAnimations];
}
}
結果が一致しません。ときどき正しい向きになり、時には逆さまになります。
私はLandcapeRightからLandscapeLeftに(そして逆も)うまくいきますが、問題はポートレートモードになったときだけです。
私が間違っていることは何ですか?
これを試しました。動作しません。理由を知らないと、オリエンテーションの変更とナビゲーションを組み合わせると、多くの人がこの問題を抱えていることがわかりました。 – urilevy2
うーん、これは私にとってはうまくいく。私が持っている傾向がある唯一の問題は、私がUIDeviceOrientationUnknownと他の方向に応答していることを確認することです。しかし、私はペン先を使わない。私はすべてをコードしているので、それは問題がないのかもしれません。私はまだsetStatusBarOrientationの使用を避けるべきだと思います。これはデバイスの向きを実際に変更しないためです。デバイスの向きを教えても、ステータスバーの向きを他の何か。 – ader
私はこれを前に試したときに逃したものは分かりませんが、今は動作します!ありがとう!! – urilevy2