经过设置,启动显示不了tabbar control
经过设置,启动显示不了tabbar control,请指教
新建一个 window-base appliction
双击 mainwindow.xib
从library 拖一个tabbar control到mainwindow.xib窗口
保存
返回xcode
在主类.h文件
添加
主类.m
为什么启动程序没有显示新建的tabbar control,而是显示window?
------解决方案--------------------
需要在IB里手动关联tabcontroller到appdelegate里定义的tabcontroller变量.
------解决方案--------------------
IB 这个东西很容易把人搞糊涂了,而且一旦出问题也不好查找。
设计的想法是好的:UI设计与编码设计分离
只是太不好用了,更多还是喜欢用代码敲,而不是用IB布局。
------解决方案--------------------
关联类似MS系统下的事件注册。
新建一个 window-base appliction
双击 mainwindow.xib
从library 拖一个tabbar control到mainwindow.xib窗口
保存
返回xcode
在主类.h文件
添加
- C/C++ code
#import <UIKit/UIKit.h> @interface tabbarTestAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; UITabBarController *tabBarController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UITabBarController *tabBarController; @end
主类.m
- C/C++ code
@synthesize tabBarController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [self.window addSubview:tabBarController.view];//这里应该是启动显示tabbar control吧? [self.window makeKeyAndVisible]; return YES; } [tabBarController release];
为什么启动程序没有显示新建的tabbar control,而是显示window?
------解决方案--------------------
需要在IB里手动关联tabcontroller到appdelegate里定义的tabcontroller变量.
------解决方案--------------------
IB 这个东西很容易把人搞糊涂了,而且一旦出问题也不好查找。
设计的想法是好的:UI设计与编码设计分离
只是太不好用了,更多还是喜欢用代码敲,而不是用IB布局。
------解决方案--------------------
关联类似MS系统下的事件注册。