我已经创建了一个项目在那里的 default.png 睡3秒钟后 MainWindow.xib 载我想创建一个新的 IntroPageViewController.xib 之前 FirstPageViewController.xib 载荷。我想要把一些文字在IntroPage其负荷的10秒钟,有一个跳过按钮。我已经创建的 FirstPageViewController.xib 现在我想要负载 IntroPageViewController.xibapplicationdidfinishlaunching .

我试图改变的 FirstPageAppDelegate.h 和。m但仍然的 FirstPageViewController.xib 载荷如果我做出改变 info.plist 加载 IntroPageViewController.xibIntroPageViewController 该应用程序的崩溃。需要帮助请。

由于一吨提前)

问候, 编码器

有帮助吗?

解决方案

而不是载入IntroPageViewController.xib前FirstPageViewController.xib手动,试试这个:

  • 当FirstPage载荷的,显示 IntroPage图在它的上面。
  • 在延迟之后,或当跳过按钮 按下,删除IntroPage.

如下:

做一个IntroPageViewController与相应的xib文件。
在模式,设置一个按钮和行动方法那个按钮。

// in your .h file.   

@interface IntroViewController : UIViewController {
    UIButton *skipButton;
}  

@property (nonatomic, retain) IBOutlet UIButton *skipButton;

-(IBAction)skipPressed;

@end  

// in the .m file  

-(IBAction)skipPressed {
    [self.view removeFromSuperview]; // this removes intro screen from the screen, leaving you FirstView
}

// put this in the viewDidLoad method
- (void)viewDidLoad {
    [super viewDidLoad];

    [self performSelector:@selector(skipPressed) withObject:nil afterDelay:5];
}

// add these in FirstViewController.m  

#import "IntroViewController.h"  

- (void)viewDidLoad {
    [super viewDidLoad];

    IntroViewController *introViewController = [[IntroViewController alloc] initWithNibName:@"IntroViewController" bundle:[NSBundle mainBundle]];
    [self.view addSubview:introViewController.view];
    [introViewController release]; // this removes your IntroScreen from memory once it disappears offscreen
}

现在,下一步是开IntroViewController.xib在接口的建设者和拖UIButton来看,设置其标题为"跳过".

连接的按钮 skipPressed 行动和连接文件的所有人按钮。

回去工业化和 建立并运行 来测试它。如果一切都很好,你IntroView应可见,在启动时间为5秒或直到你触摸跳过按钮。

其他提示

使用的NSTimer创建一些计时器。相应的动作将10秒之后执行或跳过按钮时将被压。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top