我知道是否有一个名为Default.png的文件会自动显示图像。 但是,我想在展示过程中更改图片。仅供参考,我有2张图片Default.png和default2.png。 我想在show Default.png后显示default2.png。 我尝试了下面的代码,但没有奏效。 我需要做什么?如何在应用程序启动时显示2个介绍视图?
-(BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
//..................................................................
//self.window bullabulla~
[self performSelectorOnMainThread:@selector(showIntro2View) withObject:nil waitUntilDone:YES];
//[self showIntro2View]; //also tried this, but not work.
[self.window addsubview:tabbarController];
[self.window makeKeyAndVisible];
}
-(void) showIntro2View {
UIImageView *intro2 = [[UIImageView alloc]initwithframe:cgrectmake(0,0,320,460)];
intro2.image = [UIImage imagenamed:@"default2.png"];
[self.window addSubview:intro2];
[self.window bringSubviewToFront:intro2];
[NSThread sleepfortimeinterval:2];
}
为什么使用performSelectorOnMainThread? ?你已经在主线程中! ,你能告诉我们这个代码的结果是什么吗? – ahmad 2012-07-24 09:20:57
只显示主视图。我也试过[self showIntro2View],而不是MainThread与sleepcode,但它是一样的。 – user1471568 2012-07-24 09:39:52