我在应用程序的开头获得了一个不同的图像,就像一个启动画面,然后我得到了我放在编码中的实际图像。
我在我的didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.rootViewController = self.tabBarController;
self.tabBarController.delegate=self;
[window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
LoginViewController *vc = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
self.loginNav = [[UINavigationController alloc] initWithRootViewController:vc];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
if([userDefaults valueForKey:@"UserName"] &&[userDefaults valueForKey:@"Password"])
{
vc.username=[userDefaults valueForKey:@"UserName"];
vc.password=[userDefaults valueForKey:@"Password"];
vc.autoLogin=YES;
[vc loginSelectorMethod];
}
else
{
[self.window addSubview:self.loginNav.view];
[self.window makeKeyAndVisible];
}
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashView.image = [UIImage imageNamed:@"splashscreen.png"];
[window addSubview:splashView];
[window bringSubviewToFront:splashView];
[self performSelector:@selector(removeSplash) withObject:nil afterDelay:3.0];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
NSLog(@"Registering for remote notifications");
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
return YES;
}
在启动画面出现之前,会出现“Arrow.png”图像,然后我的启动画面出现。 如果我删除“Arrow.png”,那么代替该图像会出现另一个图像,即“aboutus.png”,就像它继续一样。
我在我的项目中搜索了“Arrow.png”,它只在我整个项目的编码中出现过一次。
请指导我 非常感谢我提前
答案 0 :(得分:3)
在这里你将子视图添加为像贝娄那样的标签栏。
[window addSubview:tabBarController.view];
添加loginview后如下...
[self.window addSubview:self.loginNav.view];
然后你就像下面一样添加闪屏..
splashView.image = [UIImage imageNamed:@"splashscreen.png"];
[window addSubview:splashView];
所以这就是你看到屏幕而不是闪屏的问题。
使用以下代码...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashView.image = [UIImage imageNamed:@"splashscreen.png"];
[window addSubview:splashView];
[window bringSubviewToFront:splashView];
[self performSelector:@selector(removeSplash) withObject:nil afterDelay:3.0];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
NSLog(@"Registering for remote notifications");
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
return YES;
}
并在removeSplash
方法中将此视图添加为窗口的子视图,如下所示..
-(void)removeSplash{
[splashView removeFromSuperView];
LoginViewController *vc = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
self.loginNav = [[UINavigationController alloc] initWithRootViewController:vc];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
if([userDefaults valueForKey:@"UserName"] &&[userDefaults valueForKey:@"Password"])
{
vc.username=[userDefaults valueForKey:@"UserName"];
vc.password=[userDefaults valueForKey:@"Password"];
vc.autoLogin=YES;
[vc loginSelectorMethod];
}
else
{
[self.window addSubview:self.loginNav.view];
[self.window makeKeyAndVisible];
}
}
答案 1 :(得分:2)
嘿babul你在你的项目设置中设置了任何启动图像,或者你在项目包中放置了任何名为“Default.png”的图像这种图像在启动我们的应用程序时自动被OS检测到请检查这2点。
编辑: -
嘿babul比问题是TabBar& LoginView& splaceImage。这样做可以解决你的双重问题。
首先在你的DidFinishLaunching方法中添加以下代码
//延迟您显示您的splace图像的时间 int64_t delayInSeconds = 5.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
//Do need Full like Add Login View or Add TabbBar
//Remove SplaceImageView From Window
});
splashView = [[UIImageView alloc] initWithFrame:self.window.frame];
splashView.image = [UIImage imageNamed:@"Default-Portrait~ipad.png"];
[self.window addSubview:splashView];
[self.window bringSubviewToFront:splashView];
return YES;
还有一件事就是添加默认的splace图像,如
for iPhone Portrait Default.png。 适用于iPad Portrait Default-Portrait~ipo.png 作为默认图像的苹果文档,然后检查。 谢谢。
答案 2 :(得分:1)
可能对您有所帮助......
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
*)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
self.sql_ = [SQLDb initEngine];
[self setupControllers]; /// Set up Yor ToolBar Controller
self.hvController = [[HomeViewController alloc] init];
self.window.rootViewController = self.hvController;
[self.window makeKeyAndVisible];
[self setupSplash];
return YES;
}
-(void) setupSplash
{
self.imvSplash = [[UIImageView alloc] initWithFrame:self.window.bounds];
if( IS_IPHONE_5 )
[self.imvSplash setImage: [UIImage imageNamed:@"Default-568h@2x.png"]];
else
[self.imvSplash setImage: [UIImage imageNamed:@"splash.png"]];
[self.window addSubview: self.imvSplash];
[NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector:@selector(hideSplash:) userInfo:nil repeats:NO];
}
- (void)hideSplash:(NSTimer *)theTimer
{
[UIView animateWithDuration:1.0
delay:0.1
options: UIViewAnimationCurveEaseOut
animations:^{
self.imvSplash.alpha = 0.0;
self.ngNavigationController.view.alpha = 1.0;
}
completion:^(BOOL finished)
{
//[self.ngController setupImageAction];
[self.imvSplash removeFromSuperview];
}];
}