iOS 7启动图像(闪屏)淡出
在iOS 7上,启动图像淡入淡出,而不是在加载应用程序时立即消失。iOS 7启动图像(闪屏)淡出
有没有设置防止这个启动图像淡出动画? 我需要它立即消失,就像在iOS 6和更早版本中一样。
编辑答案:
是的,这是可能的飞溅图像添加为一个UIImageView顶端窗口,隐藏飞溅的动画渐变完成后。但是这导致了我试图避免的延迟0.4秒。
我怀疑有更回事。在应用程序周期开始时放入一些日志语句,因为在App Delegate方法被调用时出现初始屏幕,请登录并在必要时使用Instruments以查看启动时正在发生的事情。也可以尝试在重新启动之前结束应用程序上的多任务处理,以查看是否有所作为,并尝试新的空应用程序以查看体验是否相同。你没有指出应用程序在启动时会做什么,但是有没有你编码的动画可以影响启动时的淡入淡出效果?
我有同样的问题,开发具有的Cocos2D-X的应用程序,有我的主窗口和OpenGL内容初始化
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
相反,我这
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
,现在搬到方法不再“褪色”。注意将而不是确实。但是,此方法在iOS6和更高版本上可用,因此如果您希望应用程序与iOS5.x兼容并且较低,则只需执行< __IPHONE_6_0的预处理器版本检查并使用“didFinishLaunching”方法,因为它不是甚至是一个问题。
谢谢!这也适用于标准视图控制器。 –
它用cocos2d-x v2.2.5为我工作,但升级到3.2失败再次,我看到一个黑色屏幕再次褪色 –
是的,这不适合我。在Cocos2d-x的v3.9中仍然消失。 – aardvarkk
在iOS系统7,从开机画面到你的第一个UIView的启动画面淡入的转变。如果该UIView看起来与启动画面相同,则看不到任何淡入淡出。问题是Cocos2D的初始视图是纯黑的。
不幸的是,唯一的办法,我发现来解决,这是实际添加相同的开机画面一个UIImageView一秒钟,然后将其删除一次的Cocos2D开始画。
在CCDirectorIOS(或子类):
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_WIDESCREEN (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height > 567.0f)
static const NSInteger tempSplashViewTag = 87624;
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSString *spriteName = IS_IPAD ? @"Default-Landscape" : IS_WIDESCREEN ? @"Default-568h" : @"Default";
UIImageView *splashView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:spriteName]];
splashView.tag = tempSplashViewTag;
[self.view addSubview:splashView];
[self startAnimation];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
UIView *splashView = [self.view viewWithTag:tempSplashViewTag];
[splashView removeFromSuperview];
});
}
请参阅我在OP中的编辑。 – erkanyildiz
@erkanyildiz从什么时候开始0.4秒?我发现从 - [viewDidAppear]工作得很好。 0.4秒等待时间相当长。 – Patrick
我只是想确认,因为它涉及到的cocos2d应用帕特里克的答案,并添加更多的一些细节,以及。
行为确实是很容易看到,如果你一个6.1的模拟器和7.x模拟器之间切换 - 第一次做一个即时开关(带可能是一个黑色的闪光,出于同样的原因),而7.x的模拟器会对黑色进行缓慢而令人讨厌的淡入淡出,随后是Cocos2D场景的闪烁。
如果你不想修改或子类CCDirector的东西,你也可以用他的相同的代码来修改你的AppDelegate。在我们的例子中,这很简单:
- 在appDidFinishLaunching ...我们等待直到glView被创建,然后将UIImage作为子视图添加到它;
- 然后,我们创建一个“postDidFinish ...”例程,并执行选择器在0.1f秒左右后调用它。在那里,你可以使用相同的代码从RemoveSubview中移除。
它不像添加到CCDirector类那样优雅和隐蔽,但它很容易作为一个快速修复!
我已经设法在AppController中做到这一点。只需在创建glView后立即放置此代码
UIImage* image = [UIImage imageNamed:[self getLaunchImageName]];
if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)])
{
float screenScale = [[UIScreen mainScreen] scale];
if (screenScale > 1.)
image = [UIImage imageWithCGImage:image.CGImage scale:screenScale orientation:image.imageOrientation];
}
UIImageView *splashView = [[UIImageView alloc] initWithImage:image];
[viewController.view addSubview:splashView];
[splashView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.1f];
这很容易。只需获取启动图像,并在延迟后使其消失。您将需要getLaunchImage代码(基于this comment,不与iPhone 6也不6个加测试)
-(NSString*)getLaunchImageName
{
NSArray* images= @[@"LaunchImage.png",
@"[email protected]",
@"[email protected]",
@"[email protected]",
@"[email protected]",
@"[email protected]~ipad.png",
@"[email protected]~ipad.png",
@"LaunchImage-700-Portrait~ipad.png",
@"LaunchImage-Portrait~ipad.png",
@"[email protected]~ipad.png",
@"[email protected]~ipad.png",
@"LaunchImage-Landscape~ipad.png",
@"LaunchImage-700-Landscape~ipad.png",
@"[email protected]",
@"[email protected]",
@"[email protected]",
];
UIImage *splashImage;
if ([self isDeviceiPhone])
{
if ([self isDeviceiPhone4] && [self isDeviceRetina])
{
splashImage = [UIImage imageNamed:images[1]];
if (splashImage.size.width!=0)
return images[1];
else
return images[2];
}
else if ([self isDeviceiPhone5])
{
splashImage = [UIImage imageNamed:images[1]];
if (splashImage.size.width!=0)
return images[3];
else
return images[4];
}
else if ([self isDeviceiPhone6])
{
splashImage = [UIImage imageNamed:images[1]];
if (splashImage.size.width!=0)
return images[13];
else
return images[14];
}
else
return images[0]; //Non-retina iPhone
}
else if ([[UIDevice currentDevice] orientation]==UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown)//iPad Portrait
{
if ([self isDeviceRetina])
{
splashImage = [UIImage imageNamed:images[5]];
if (splashImage.size.width!=0)
return images[5];
else
return images[6];
}
else
{
splashImage = [UIImage imageNamed:images[7]];
if (splashImage.size.width!=0)
return images[7];
else
return images[8];
}
}
else
{
if ([self isDeviceRetina])
{
splashImage = [UIImage imageNamed:images[9]];
if (splashImage.size.width!=0)
return images[9];
else
return images[10];
}
else
{
splashImage = [UIImage imageNamed:images[11]];
if (splashImage.size.width!=0)
return images[11];
else
return images[12];
}
}
}
-(BOOL)isDeviceiPhone
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
return TRUE;
}
return FALSE;
}
-(BOOL)isDeviceiPhone4
{
if ([[UIScreen mainScreen] bounds].size.height==480)
return TRUE;
return FALSE;
}
-(BOOL)isDeviceRetina
{
if ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] &&
([UIScreen mainScreen].scale == 2.0)) // Retina display
{
return TRUE;
}
else // non-Retina display
{
return FALSE;
}
}
-(BOOL)isDeviceiPhone5
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && [[UIScreen mainScreen] bounds].size.height==568)
{
return TRUE;
}
return FALSE;
}
-(BOOL)isDeviceiPhone6
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && [[UIScreen mainScreen] bounds].size.height>568)
{
return TRUE;
}
return FALSE;
}
如果这真的是你的代码,你可能在图像名称的拼写错误。 (如果没有,让我们知道什么“不工作”的意思)。
此外,启动画面通常不会出现在每个应用程序的DIDBecomeActive :. didFinishLaunchingWithOptions:是你知道你已经启动并且闪屏已经以你的名义显示的时间。
-(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[UIView animateWithDuration:0.2
delay:0
options: UIViewAnimationCurveEaseIn // change effect here.
animations:^{
self.window.viewForBaselineLayout.alpha = 0; // and at this alpha
}
completion:^(BOOL finished){
}];
return YES;
}
好了,不要指望使用打破了NDA,最好的办法是要求对开发商论坛 – rckoenes
有人问大约一个月前,但至今没有回应这个问题。相信与否,Apple Dev Forums是讨论iOS开发最无用的地方。 – erkanyildiz
虽然这是事实,但人们可能不希望通过在此讨论NDA来打破NDA。 – rckoenes