一段时间后通过动画将视图从一个 xib 更改为另一个 xib
我制作了一个基于视图的应用程序,它正在加载默认视图...
我的默认视图是启动屏幕..
我想要实现的是一旦默认视图(启动视图)完成加载,几秒钟后它会加载另一个视图,即隐私政策或应用程序屏幕。
AppDelegate.m 中的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
照常没有变化...
上面的代码从splashscreen.xib 文件加载视图
以下代码位于splashscreen.m
- (IBAction)loadPrivacyScreen {
NSLog(@"Switching To Another View");
PrivacyPolicyView *modal = [[PrivacyPolicyView alloc]initWithNibName:nil bundle:nil];
modal.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:modal animated:YES];
[modal release];
}
- (void)viewDidLoad {
[super viewDidLoad];
sleep(3);
[self loadPrivacyScreen];
// Do any additional setup after loading the view from its nib.
}
三秒后,它确实进入了loadPrivacyScreen 函数,但没有加载视图。
- (IBAction)loadPrivacyScreen;
我创建了一个名为 IBAction 的方法,因为我想将该方法与隐私屏幕上的按钮挂钩,以检查该功能是否有效......
令人惊讶的是,当您单击该按钮时它会起作用。但它不能按时工作。
谁能建议我我做错了什么?或任何其他替代方案来实现相同的目标?
注意:我也尝试更改
- (IBAction)loadPrivacyScreen;
为
- (void)loadPrivacyScreen;
但结果仍然相同。不是切换的....
I have made a view based application which is loading a default view ...
My default view is a splash screen ..
What I want to achieve is once default view (splash view) finished loading, after few seconds it loads another view which is either a privacy policy or application screen.
Code in AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
No Change as usual ...
Above code load a view from splashscreen.xib file
Following code is in splashscreen.m
- (IBAction)loadPrivacyScreen {
NSLog(@"Switching To Another View");
PrivacyPolicyView *modal = [[PrivacyPolicyView alloc]initWithNibName:nil bundle:nil];
modal.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:modal animated:YES];
[modal release];
}
- (void)viewDidLoad {
[super viewDidLoad];
sleep(3);
[self loadPrivacyScreen];
// Do any additional setup after loading the view from its nib.
}
After three second it does get in to the loadPrivacyScreen funciton but doesn't load the view.
- (IBAction)loadPrivacyScreen;
I have created a method as IBAction because I want to hook that method with a button on privacy screen to check that function works ...
And surprisingly it works when you click the button. But it doest work on time.
Can anyone suggest me what am I doing wrong ?? or any other alternative to achieve same thing??
Note: I have also try changing
- (IBAction)loadPrivacyScreen;
to
- (void)loadPrivacyScreen;
But still same result. It is not switching ....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,iOS 提供了一种简单的方法来加载闪屏。
只需添加一个名为 default.png 的分辨率为 320x480 的图像,并将其添加到您的项目中,它就会自动使用该图像作为启动屏幕图像。
以您的方式调用带有计时器的 loadPrivacy 屏幕。
First of all iOS provides a simple way to load a splash screen.
Just add a Image with 320x480 resolution in the name called default.png and add that to your project it will automatically use this image as splash screen image.
In your way call the loadPrivacy screen with a timer.
在视图控制器中,定义一个类似的方法
And in the view controller, define a method like