2011-10-12 23 views
5

我目前在模態視圖和彈出窗口中遇到了一些問題。這可能是同樣的問題,但我不確定。無法更改Xcode(iPad)中模式視圖的顯示和轉換樣式

我對模態視圖的問題是我無法更改動畫或過渡樣式。例如,我寫

self.modalPresentationStyle = UIModalPresentationPageSheet; 
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
[self presentModalViewController:IpModal animated:YES]; 

但模態視圖仍然以其原始過渡樣式全屏顯示。

此外,我與popovers的問題非常相似。儘管我將「no」作爲參數調用dismissPopover:animated:方法,但過渡仍是動畫。

在此先感謝。

回答

1

也許你可以嘗試使用這兩種方法之一來呈現popover控制器,具體取決於你想要顯示的位置,而不是presentModalViewController:animated:

– presentPopoverFromRect:inView:permittedArrowDirections:animated: 
– presentPopoverFromBarButtonItem:permittedArrowDirections:animated: 
24

modalPresentationStylemodalTransitionStyle應用於視圖控制器要呈現模態,不是控制器操作的方式的呈現。

你的代碼應該是

IpModal.modalPresentationStyle = UIModalPresentationPageSheet; 
IpModal.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
[self presentModalViewController:IpModal animated:YES]; 
+0

+1這也適用於設置在目標視圖控制器的風格,通過將其設置爲自己來解散回來。例如,通過強制觸摸預覽viewcontroller的情況下,通過在目的地側執行設置解散的轉換似乎是靈活的。 – haxpor

4

我在定製SEGUE這樣做。

UIViewController* src = self.sourceViewController; 
UIViewController* dst = self.destinationViewController; 

src.modalPresentationStyle = UIModalTransitionStyleFlipHorizontal; 
dst.modalPresentationStyle = UIModalTransitionStyleFlipHorizontal; 
[src presentModalViewController:dst animated:YES]; 
2
#import yourViewController.m //already present 
#import destinationVieController.m //to be added by programmer 

//custom function to call destination controller 

-(void)callDestinationViewController{ 

    destinationViewController *dest = [[destinationViewController alloc] initWithNibName:@"destinationViewController" bundle:nil]; 

    dest.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
    [self presentModalViewController:dest animated:YES]; 

    } 

//custom function can be called on event fire or action call 

希望這有助於!