1

How do I make my app seamless from the default.png to my App? Should I load it somewhere else? FYI I only have an iPod Touch 2nd Gen for testing running 4.2.1(8C148) The 4.2 simulator does the same thing. 4.3 simulator works fine.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:YES]]];
    // Override point for customization after application launch.

    // Add the view controller's view to the window and display.
    [self.window addSubview:viewController.view];
    [self.window makeKeyAndVisible];

    return YES; 
}
Bonny
  • 2,038
  • 1
  • 14
  • 15
user864465
  • 83
  • 1
  • 8

1 Answers1

2

What is happening it is taking a few seconds before UIWebView fully loads its content. So whilst it is loading, you are seeing the background color of the web view. If you don't want the blank screen, I would advise showing an activity indicator, to show that something is happening.

Alternatively, set the webViews delegate as your self and only perform [self.window makeKeyAndVisible] in the webView' delegate message named `webView:didFinishLoad‘

The latter method is unadvisedly though, as your effectively delaying the start of your app for several seconds.


In viewDidLoad,

webView.delegate = self;

Now in a separate method, called -(void)webViewdidFinishLoad:(UIWebView *)theWebView

[imageView removeFromSuperview]
[imageView release]
Benjamin Mayo
  • 6,649
  • 2
  • 26
  • 25
  • The purpose of the launch image is to give the appearance of the app loading quickly. Like the built-in stocks app, weather,settings... My Default.png does exactly that. It looks exactly like my first screen without the data. Having it disappear followed by a gray screen then to have my app screen appear looks bad. My webView is screaming fast and it is local. If there is not a way to get rid of it I would be best served by not using a launch image at all. I just hate to spend my tech support requests with Apple but there must be a way to fix this. – user864465 Jul 27 '11 at 08:03
  • If there's not content their when you makeKeyAndVisible, you will get that flash. It's the webView load that is causing it. – Benjamin Mayo Jul 27 '11 at 08:09
  • Thanks Benjamin, I am fairly new at this. Could I not create a UIImageView first and have it also load the Default.png for that 1 second flash or will I still just get the flash after that? I'm not even quite sure how to do that but I will find out. :) – user864465 Jul 27 '11 at 22:03
  • You could have the image view, and remove it in webView:didFinishLoad, to stop the flash. – Benjamin Mayo Jul 27 '11 at 22:21
  • so, I created an imageview but I cannot get rid of it so the webview is visible.. NSString* imagePath = [ [ NSBundle mainBundle] pathForResource:@"Default" ofType:@"png"]; UIImage *image = [ UIImage imageWithContentsOfFile: imagePath]; UIImageView *imageview = [ [ UIImageView alloc] initWithImage: image ]; imageview.image = image; [self.view addSubview:imageview]; [image release]; How do I remove it? I appreciate your advice on this Benjamin. – user864465 Jul 28 '11 at 07:05
  • You need an instance variable of your image view to start with. Then using delegation, you will remove the imageView at the appropriate time. Look at the original post, I'll add code their. – Benjamin Mayo Jul 28 '11 at 07:19
  • Guess I'm slow..er.. I did all of the above as suggested and now I get build succedded with warnings, "local declaration of ImageView hides instance variable. If I reaname ImageView I am warned to declare it. It still is not working though. The launch image works followed by my ImageView and then I can see the activity indicator loading my page under the image but I cannot seem to release the image or hide it. If I could get it to disappear as soon as the webView begins to load would be ideal. I'll see if I can put my code up above. – user864465 Jul 29 '11 at 09:09
  • Change `UIImageView *ImageView =` to just `ImageView =` – Benjamin Mayo Jul 29 '11 at 10:31
  • Woops I meant change `UIImageView *myImage =` to `myImage =` – Benjamin Mayo Jul 29 '11 at 21:03
  • WORKS PERFECT! [myImage setHidden:TRUE]; if I use the remove from superView I get no errors but it crashes and closes the app. I set the background color to the same as my data area and set the data area in my image to transparent. It works exactly as I wanted. Thank You,Thank You, Thank You Benjamin! I'll send you a coupon for my app when I'm done if you want to e-mail me. – user864465 Jul 30 '11 at 01:45
  • Could you also tell me how to display a different image on orientation change or should I post a new question? -Brad – user864465 Jul 30 '11 at 03:28
  • Just post a new question. This comment thread is getting a bit long. – Benjamin Mayo Jul 30 '11 at 07:07