我想從一個視圖(一個完全正常的視圖)切換到另一個視圖(也是正常的)可編程。這是我現有的代碼:如何切換到現有的非導航控制器視圖可編程?
- (IBAction)login:(id)sender {
if([_username.text isEqualToString:name] && [_password.text isEqualToString:pw]) {
DashboardViewController *destinationController = [[DashboardViewController alloc] init];
[self.navigationController pushViewController:destinationController animated:YES];
}else {
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Wrong Username or Password!"
message:@"Sorry."
delegate:nil
cancelButtonTitle:@"Okay"
otherButtonTitles:nil, nil];
[message show];
_password.text = nil;
}
}
所以,我希望得到指向我DashboardViewController
。如果我嘗試這個代碼,會顯示一個黑色的空白視圖。它有什麼問題?
您是否有稱爲DashboardViewController.xib的xib或者DashboardViewController在loadview中創建它自己的視圖?看起來也許你沒有加載視圖。 –
我正在使用故事板(無筆尖文件)。 Abdullah Shafique的回答非常有幫助! – Kitzng