default.png 文件之后、MainWindow.nib 之前有 5 秒的介绍页面

发布于 2024-08-23 06:10:32 字数 656 浏览 9 评论 0原文

我创建了一个项目,其中 default.png 休眠 3 秒,然后加载 MainWindow.xib 我想创建一个新的 IntroPageViewController.xib 在 FirstPageViewController.xib 加载之前。我想在 IntroPage 中放入一些文本,该文本加载 10 秒并有一个跳过按钮。 我已经创建了 FirstPageViewController.xib ,现在我想在 applicationdidfinishlaunching 中加载 IntroPageViewController.xib

我尝试在 FirstPageAppDelegate.h 和 .m 中进行更改,但是 FirstPageViewController.xib 仍然会加载,并且如果我对 info.plist 进行更改加载 IntroPageViewController.xibIntroPageViewController 应用程序崩溃。 需要帮助请。

提前非常感谢:)

问候, 编码员

I had created a project where the default.png sleeps for 3 seconds and then the MainWindow.xib is loaded I wanted to create a new IntroPageViewController.xib before the FirstPageViewController.xib loads . I wanted to put some text in the IntroPage which loads for 10 seconds and has a skip button .
I already created the FirstPageViewController.xib , now I want to load IntroPageViewController.xib in applicationdidfinishlaunching .

I tried to make changes in the FirstPageAppDelegate.h and .m but still the FirstPageViewController.xib loads and if I make changes to info.plist to load IntroPageViewController.xib or IntroPageViewController the application crashes .
Help needed please .

Thanks a ton in advance :)

Regards,
Coder

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月下伊人醉 2024-08-30 06:10:32

不要在 FirstPageViewController.xib 之前手动加载 IntroPageViewController.xib,而是尝试以下操作:

  • 当 FirstPage 加载时,显示
    IntroPage 视图位于其顶部。
  • 延迟后或跳过按钮按下时
    按下后,移除 IntroPage。

方法如下:

使用相应的 xib 文件创建一个 IntroPageViewController。
在 Xcode 中,设置一个按钮和该按钮的操作方法。

// 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
}

现在下一步是在 Interface Builder 中打开 IntroViewController.xib 并将 UIButton 拖到视图中,将其标题设置为“Skip”。

将按钮连接到 skipPressed 操作,并将文件所有者连接到按钮。

返回 Xcode 并构建并运行来测试它。如果一切顺利,您的 IntroView 应在启动时可见 5 秒或直到您触摸“跳过”按钮。

Instead of loading the IntroPageViewController.xib ahead of the FirstPageViewController.xib manually, try this:

  • When the FirstPage loads, show the
    IntroPage view on top of it.
  • After a delay or when skip button is
    pressed, remove the IntroPage.

Here's how:

Make an IntroPageViewController with corresponding xib file.
In Xcode, setup a button and an action method for that button.

// 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
}

Now the next step is to open IntroViewController.xib in Interface Builder and drag a UIButton to the view, set its title to 'Skip'.

Connect the button to the skipPressed action and connect File's Owner to the button.

Go back to Xcode and Build and Run to test it. If all is well, your IntroView should be visible at launch time for 5 seconds or until you touch the Skip button.

梦醒灬来后我 2024-08-30 06:10:32

使用 ntimer 创建一些计时器。 10 秒后或按下跳过按钮时将执行相应的操作。

use nstimer to create some timer. The corresponding action will be executed after 10 sec or when skip button will be pressed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文