Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to push a landscape view from within a uinaviagtioncontroller, whose initial view is in portrait... So you click a button, or tableviewcell, and the screen rotates 90° into the new view..

How would I manage that? This is similar to how the Youtube app works when transitioning from movie info screen to the actual movie.

(note: i am not interested in what rotation the user is holding the device)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
332 views
Welcome To Ask or Share your Answers For Others

1 Answer

Implement the following method, which should be called when the view is pushed onto the navigation stack:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

This should automatically rotate everything sideways as soon as you push it on to the stack, since the view does not support portrait orientations.

If I'm wrong and it doesn't, you can always force horizontal orientation by setting the status bar orientation:

- (void) viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:animated];
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...