所以我得到這個按鈕,if
聲明推到StartViewController
。我在這個視圖控制器的viewDidLoad
中做了一個[email protected]"transition successful"
來檢查是否進行了轉換。ViewControllers之間的轉換不工作
在日誌中顯示轉換成功,但在屏幕上沒有轉換。
下面是代碼:
-(IBAction)initialButton:(id)sender {
NSLog(@"initialButton clicked");
if([userEmail.text length] <4)
{
[WCAlertView showAlertWithTitle:@"Email is empty" message:@"You haven't entered an email yet. Please enter one so we can sent you the shipping labels." customizationBlock:^(WCAlertView *alertView) {
alertView.style = WCAlertViewStyleBlackHatched;
} completionBlock:^(NSUInteger buttonIndex, WCAlertView *alertView) {
if (buttonIndex == 0) {
NSLog(@"Cancel");
} else {
NSLog(@"Ok");
}
} cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
}
else
{
StartViewController *startViewController = [[StartViewController alloc] init];
self.transitionController = [[[TransitionController alloc] initWithViewController:startViewController] initWithNibName:@"StartViewController" bundle:nil];
[initialViewController.view removeFromSuperview];
self.window.rootViewController = self.startViewController;
}
}
這裏是日誌:
2012-12-14 09:22:55.431 Janssenpakketapp[24165:c07] initialViewController loaded
2012-12-14 09:23:04.021 Janssenpakketapp[24165:c07] initialButton clicked
2012-12-14 09:23:06.116 Janssenpakketapp[24165:c07] Ok
2012-12-14 09:23:11.909 Janssenpakketapp[24165:c07] initialButton clicked
2012-12-14 09:23:11.911 Janssenpakketapp[24165:c07] transition succesful
初始化實例然後刪除那個視圖,所以我認爲這就是爲什麼它的打印「NSLog」,但沒有在屏幕上顯示任何東西!我不明白爲什麼你使用'removeFromSupreView'然後將其實例賦值給'rootViewController'?你能解釋一下嗎? –
哦,我的錯誤startViewController應該是InitialViewController。這就是我們現在正在使用的視圖控制器。但是如果我刪除那部分,它仍然不起作用。 –
我如何釋放當前的視圖控制器? –