我是Objective-C和iOS中的新手。我跟着UINavigationController。iOS 5.1中的UINavigationController
在視頻的第一個2:30分鐘,他使用AppDelegate接口和實現,並提供了一些代碼,我沒有在我的應用程序中。
在他的界面:
@Class ViewController;
...
@property(strong, nonatomic) ViewController *viewController;
,我沒有。
而在AppDelegate中實施之前,他開始定義navigationViewController
,他在didFinishLaunchingWithOption
喜歡代碼的某些行:
self.windows = [[UIWindows alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
self.windows.rootViewController = self.viewController;
[self.windows makeKeyAndVisible]
return YES;
我上self.viewController
警告。
,但我只是有:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}
爲了尼克斯的NavigationViewController,他補充說這一行:
UINavigationController *navigationViewController = [[UINavigationController alloc] initWithRootViewController:self.viewController
self.windows.rootViewController = navigationViewController;
當我加入這個代碼,我遇到一個錯誤(在月底self.viewController
警告) 。 當我運行該項目時,它只顯示頂部的導航,但之前創建的TableView消失了。 你能幫我解決這個問題嗎?我的模擬器是5.1版本。
謝謝,但正如我在介紹的標題欄和結尾說的XCode 5.1。 AppDelegate不包含這些代碼。 – Ali 2012-07-28 21:26:07
5.1是iOS SDK。這些說明應該適用於所有最新版本的XCode(或非常接近)。如上所述,創建新項目時將生成代碼。 – spacious 2012-07-28 21:59:55
我在XCode中創建了一個新項目。在AppDelegate中生成的代碼與我所說的完全一樣。但你對iOS版和XCode是正確的。我也在XCode 4.3.3中。 – Ali 2012-07-28 22:30:55