1

我正在使用此代码显示启动画面,但我看到的唯一内容是黑色。

UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil];
SplashViewController *splash = [storyBoard instantiateViewControllerWithIdentifier:@"splash"];
splash.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
splash.modalPresentationStyle = UIModalPresentationFullScreen;
[self.window addSubview:splash.view];

启动画面的视图控制器正在加载,因为正在调用断点,但我看不到视图控制器,我只看到黑色。

4

2 回答 2

0

我看到您正在使用情节提要,所以您可以这样做:

- Add view controller (VC0) to storyboard
- Set correct orientation on VC0 - your app orientation
- Add container view on VC0 (full size view)
- Add splash screen image on VC0 (full size view)
- Create UIViewController subclass - call it for example CustomSplashDisplay
- create UIImageView IBOutlet - for example vwImage
- override viewDidLoad like:

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self performSelector:@selector(HideImage) withObject:nil afterDelay:kSplashScreenDuration];
}

-(void)HideImage
{
    [vwImage setHidden:YES];
    [self.view sendSubviewToBack:vwImage];
}

在故事板中

- Set VC0 as initial view controller
- Set its class to CustomSplashDisplay
- connect UIImage outlet
- embed previous initial view controller in container view

运行一个给你...

于 2014-09-25T13:46:46.030 回答
0

我认为您可以使用它来呈现启动视图控制器,而不是添加splash.view为子视图。windowpresentViewController:animated:completion:

于 2013-08-26T09:38:26.447 回答