4

我在应用程序开始时得到一个不同的图像,比如启动屏幕,然后我得到我在编码中放置的实际图像。我在我的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”,它在我的整个项目的编码中只出现一次。

4

3 回答 3

3

在这里,您将 subiview 添加为标签栏,如下所示..

[window addSubview:tabBarController.view];

添加如下登录视图后..

[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];
    }
}
于 2013-01-10T10:29:46.250 回答
2

您是否在您的项目设置中设置了任何启动图像,或者您是否在您的项目包中放置了任何名为“Default.png”的图像,这种图像会在启动我们的应用程序时被操作系统自动检测,请检查这 2 点。

编辑:-

比问题是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图像,如

iPhone 肖像 Def​​ault.png。
对于 iPad,Portrait Default-Portrait~ipad.png
作为默认图像的苹果文档,然后检查。

于 2013-01-10T10:30:15.807 回答
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];
                                                         }];
    }
于 2013-01-10T10:36:45.817 回答