Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

iphone - How can I display one UIView in landscape?

I've looked at every question so far and none seem to actually answer this question.

I created a UITabBarController and added several view controllers to it. Most of the views are viewed in portrait, but one should be viewed in landscape. I don't want to use the accelerometer or detect when the user rotates the device, I just want to display the view in landscape mode when they choose that view from the tab at the bottom.

I want the regular animations to occur, such as the tab dropping out, the view rotating, etc., when they choose that item, and the opposite to happen when they choose a different view.

Is there not a built-in property or method to tell the system what orientation to display the view as?

Overriding the shouldautorotate... method does absolutely nothing so far as I can tell.

The type of answer I would NOT appreciate is "RTFM" because I already have, and anybody who's developed for the iPhone so far knows that there is very little useful M to F-ing R.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

An post on a forum that might help. Short answer is you have to manually rotate your view or controller once the view has been drawn, in the viewWillAppear: method

CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90));
landscapeTransform = CGAffineTransformTranslate (landscapeTransform, +80.0, +100.0);

[[appDelegate navController].view setTransform:landscapeTransform];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...