我試圖在按下按鈕時在我的應用程序中顯示「關於頁面」,但是當我按下UIButton時,調用NSLog(@「Button pressed」),但視圖將不會加載。這裏是我的代碼:加載.xib文件並顯示它
- (IBAction)pushAbout {
NSLog(@"Button pressed");
AboutView * aboutView = [[AboutView alloc] initWithNibName:@"AboutView" bundle:nil];
[self.navigationController pushViewController:aboutView animated:YES];
[aboutView release];
}
我見過一個例子的代碼,但它被稱爲在一個UITableViewController,而不是一個ordianry UIView的控制器。
類文件「AboutView」被創建爲UIViewController子類。他們創造和保持不變
您的包中是否有AboutView.xib文件? – 2011-05-05 16:33:39
是的,它與AboutView.m和AboutView.h一起添加,並且只包含標籤 – 2011-05-05 16:35:06
什麼都不會發生?或者只是出現白色視圖? AboutView.xib是否正確添加到目標?你有沒有保存你的xib文件?我有時編輯我的xib並忘記保存... – 2011-05-05 16:40:57