0

我在 iOS 6 中创建了一个新的选项卡式应用程序,
但我想在顶部添加一个图像,以便在我的项目中保持相同

AppDelegate.m文件中我添加了这段代码

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    UIViewController *viewController1 = [[LMSFirstViewController alloc] initWithNibName:@"LMSFirstViewController" bundle:nil];
    UIViewController *viewController2 = [[LMSSecondViewController alloc] initWithNibName:@"LMSSecondViewController" bundle:nil];
    UIViewController *viewController3 = [[LMSThirdViewController alloc] initWithNibName:@"LMSThirdViewController" bundle:nil];

    **UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 80, 1024)];
    imageView.image=[UIImage imageNamed:@"LMS.jpg"];**


    self.tabBarController = [[UITabBarController alloc] init];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2,viewController3,nil];

    self.window.rootViewController = self.tabBarController;
    **[self.window addSubview:imageView];**
    [self.window makeKeyAndVisible];
    return YES;
}

但它不加载任何图像
我应该怎么做才能以任何其他方式添加图像来实现这一点

谢谢,
阿伦。

4

1 回答 1

0

一旦像这样检查它就可以工作,在调用 [self.window makeKeyAndVisible]; 方法后添加子视图,之前你在加载之前添加子视图发生了什么。

self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];   
    [self.window addSubview:imageView];
于 2013-04-02T07:27:04.247 回答