我正在创建一个标签栏应用程序,但我想使用界面构建器创建不在Main.xib中的标签栏控制器。因为我的应用没有Main.Xib。所以我应该在ViewController.xib中执行它,或者在控制器/ appdelegate中以编程方式执行它。我找不到任何好的教程或示例。
在我的应用中我有
AppDelegate.h
AppDelegate.m
ViewController.h
ViewController.m
ViewController.xib
我的应用程序从ViewController.xib视图开始,知道我想添加一个标签栏,但是一个标签栏控制器,它总是保持在视图的底部。我怎么能这样做?
appdelagete.h
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
我试图通过查看apple developer docs以编程方式进行,但无法弄明白。
提前感谢任何示例代码
答案 0 :(得分:1)
我发现这很有效 appdelegate.h
@property (nonatomic, retain) UITabBarController *rootController
appdelegate.m
UIViewController *viewController1 = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.rootController = [[[UITabBarController alloc] init] autorelease];
self.rootController.viewControllers = [NSArray arrayWithObjects:viewController1, nil];
self.window.rootViewController = self.rootController;
答案 1 :(得分:0)
这将创建一个包含3个视图的标签栏
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:view1, view2, view2, nil];
self.window.rootViewController = self.tabBarController;
答案 2 :(得分:0)
/// AppDelegate.m文件:didFinishLaunchingWithOptions方法
System.Net.Mime.ContentType mimeType = new System.Net.Mime.ContentType("text/calendar; method=CANCEL");
AlternateView alternate = AlternateView.CreateAlternateViewFromString(body, mimeType);
message.AlternateViews.Add(alternate);