我目前正在开发一个横向应用程序,我希望有一个启动图像。由于启动图像不能在横向上工作,我想让我的启动图像成为一个视图,并在显示此视图后约5秒钟当应用程序启动时,视图将切换到应用程序的原始第一个视图。我该怎么做呢?我正在使用故事板。
答案 0 :(得分:1)
只需在application:didFinishLaunchingWithOptions:
方法中添加自定义视图。
UIImageView*imageView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"your_image.png"]];
[[yourFirstViewController view] addSubview:imageView];
[[yourFirstViewController view] bringSubviewToFront:imageView];
[self.window makeKeyAndVisible];
// Fade out the image
[UIView transitionWithView:self.window
duration:1.0f
options:nil
animations:^(void)
{
imageView.alpha=0.0f;
}
completion:^(BOOL finished)
{
[imageView removeFromSuperview];
}];
答案 1 :(得分:0)
我使用延迟以编程方式设置segue。
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self performSelector:@selector(enterthegame) withObject:nil afterDelay:5];
}
-(void)enterthegame{
[self performSegueWithIdentifier: @"tothegame" sender: self];
}
只需确保您有一个segue,其标识符与您的代码相匹配。可以隐藏segue连接的按钮。