好的,我明显是iOS开发新手,请耐心等待。我在Internet上看到的大多数教程都基于单个视图模板,但我想将其中的一些组合到标签栏中。我有三个属性列表,我希望将它们分配给各个选项卡并用作向下钻取导航数据。我被告知我可以将字典属性分配给应用程序didFinishLaunching方法中的单个选项卡,但我不明白如何将它们分配给不同的选项卡。多视图和应用程序委托?
因此,这里是我有什么
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window makeKeyAndVisible];
[self.window addSubview:rootViewController.view];
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *DataPath = [Path stringByAppendingPathComponent:@"LocationsData.plist"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:DataPath];
self.locationsData = tempDict;
[tempDict release];
[self.window addSubview:locNavControl.view];
[window makeKeyandVisible];
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *DataPath = [Path stringByAppendingPathComponent:@"IndustriesData.plist"];
NSDictionary *tempDict = [[NSDictionary alloc] initWithContentsOfFile:DataPath];
self.industryData = tempDict;
[tempDict release];
[self.window addSubview:indNavControl.view];
[window makeKeyandVisible];
return YES;
}
的错误是在self.window addSubview:locNavControl.view因为“请求的东西不是一个结构或联合成员‘视图’”。我想我可能会让这个部分错误,因为我希望当您按下一个选项卡时将它们推送到屏幕上。警告在makeKeyandVisible上,因为“窗口”可能不响应。
我想我做错了,但我不知道。一些帮助将不胜感激:)
那我应该用什么来代替它呢? –
你应该重新检查文档。也许从XCode中的TabBarController模板开始,在线查找一个漂亮的tabbarcontroller教程。我无法真正告诉你应该将其替换,因为我不确定你想要完成的是什么。我添加了一个关于关键窗口的小笔记给我的答案.. – mjisrawi
非常感谢。还有几个问题 - 你将如何去完成这个任务,并为应用程序didFinishLaunching方法中的每个单独的选项卡分配属性,以及如何获取代码连接?我只需进入我的mainwindow.xib并将应用程序委托连接到每个选项卡? –