2010-11-25 38 views
3

我有一個實現模式視圖使用UIModalPresentationFormSheet顯示屏幕外

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

然後一個UIViewController,我嘗試在這種觀點之上彈出一個模式:

ModalViewController *modalViewController = [[ModalViewController alloc] init]; 
modalViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
modalViewController.modalPresentationStyle = UIModalPresentationFormSheet; 
[mainViewController presentModalViewController:modalViewController animated:YES]; 

如果我啓動模式,而iPad是肖像,它工作正常。但是當我將其放在橫向上並嘗試啓動模式時,模式會出現在iPad右上角的一半以外。有任何想法嗎?

回答

4

在ModalViewController中,執行shouldAutorotateToInterfaceOrientation的方式與它在mainViewController中的方式相同(都需要同意它們支持的方向)。

+1

怎麼樣一個視圖控制器不會出現居中當我把它UIModalPresentationFormSheet?你有線索爲什麼? – 2012-01-25 17:03:54