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

Categories

0 votes
347 views
in Technique[技术] by (71.8m points)

iphone - Transitioning to landscape rotation within a uinavigationcontroller

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

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

1 Answer

0 votes
by (71.8m points)

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];
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...