2013-02-04 31 views
0

我在使用[self presentModalViewController:head animated:NO];在ios 4.3中,並尋找替代ios 5及以上。我寧願使用通用的iOS版本,但if (iOS is lower than 6)也可以很好。 我的問題是,使用[self presentViewController:head animated:YES completion:nil];作爲替代將工作只有如果animated設置爲YES。任何想法爲什麼?我不想讓它動畫。如果我是而不是使用StoryBoardspresentViewController將無法使用動畫:NO

+1

你可以包含問題的代碼片段嗎? –

+0

以上是我用來在ViewControllers之間移動的唯一代碼。 – Segev

回答

1

該應用程序是否失敗?你有NSZombies啓用?

如果你正在做這樣的事情

- (id)init { 
    self = [super init] 

    if (self) { 
     ViewController * viewController = [[ViewController alloc] init]; 
     [self presentViewController:viewController animated:YES]; 
    } 

    return self; 
} 

這是因爲視圖尚未啓動,請使用下列方法之一

- (void)viewDidAppear:(BOOL)animated { 
    [super viewDidAppear:animated]; 

    ViewController * viewController = [[ViewController alloc] init]; 
    [self presentViewController:viewController animated:YES]; 

} 

// OR 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    ViewController * viewController = [[ViewController alloc] init]; 
    [self presentViewController:viewController animated:YES]; 

} 

我明白,這可能不是回答你問題,但你沒有發佈它的發起者。但這是一個常見的錯誤,所以我認爲我會張貼它解決你的問題。

+0

我昨天就知道了。代碼在ViewWillAppear下。你的猜測是絕對正確的。謝謝 – Segev

+0

優秀。我只是回答說,因爲它的一個常見的錯誤很高興你明白了 – ninjr