开发者

shouldAutorotateToInterfaceOrientation is only called after presenting viewcontroller

When i create a project and start it without changes and the automatic created viewcontroller is loaded it calls the shouldAutorotateToInterfaceOrientation without any problem. Now i tried different methods to present an own viewcontroller, but in that view the shouldAutorotateToInterfaceOrientation will 开发者_运维百科not be called on rotation. My first try was to change the didFinishLaunchingWithOptions of app delegate in that way:

ProjectView1 *pv1 = [ProjectView1 alloc];
self.viewController = pv1;
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];

But in the ProjectView1 the shouldAutorotateToInterfaceOrientation is not called on rotating the screen.

My second try was to load the view that was created by creating the project and present my custom view modaly by calling presentModalViewController, but the result is the same my custom view controller gets no call of shouldAutorotateToInterfaceOrientation.


You should call the initWithNib method after you do the alloc for the UIViewController.

I tried replicating this scenario and following code calls the shouldAutorotateToInterfaceOrientation on orientation changes:

 ProjectView1 *pv1 = [[ProjectView1 alloc]initWithNibName:nil bundle:nil];
 self.viewController = pv1;
 self.window.rootViewController = self.viewController;
 [self.window makeKeyAndVisible];

Change the code put the right nib file name or leave it nil if you intend to build the view yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜