iphone - Code not executing as expected when loading URL into UIImageView -


I'm having trouble with my code, it seems that it never gets right.

I have tried many things from UIActivity, Slider, UITextViewer ... but it never changes,

The code runs from xCode using a Navigation based application LoadingTview is a text view,

The problem is, see what the method of loading is, which never works, it always hangs, the user presses a button, and this code executes is. LoadingTueview is a textview that is saying "loading", with alpha of 0.4, so that it will be loaded while downloading the website originally, people know its loading.

Even I tried the ideas but there was only one problem.

How can I make progress?

  loadingTview.hidden = false; Today = [NSDT Date]; DateFormat = [[NSDateFormatter alloc] init]; [DateFormat setDateFormat: @ "dd-MM-yyyy"]; Date string = [datefirm string string: today]; If (pageand == @ "page 1") {NSString * url = [NSString stringWithFormat: @ "http://www.imagegoeshere.com/%@.jpg", date string]; ImageURL = [NSURL URLWithString: url]; ImageData = [NSData Datatyh content of URL: URL]; Image = [UIImage imageWithData: imageData]; Fullscreen Image Image = image; LoadingTview.hidden = true; [Navigation controller Push ViewController: Animated vFullscreen: Yes]; }  

I'm not completely sure what the problem is, but I think that When you look at scene 2 to 3 it looks at 3, until the image loads before actually opening View3 to show the loading screen, okay?

If this is the case, what do you want to do is load your image in a different thread so that the loading screen can not be stopped by showing the loading screen.

Take a look (though there are cleaner / better ways to do this).

Actually do this in the controller of 3:

  - (zero) viewDidoadload {// & lt; First, show your 'Loading ...' screen here & gt; // Then create a thread to load the image: [NSThread detachNewThreadSelector: @selector (loadImage) toTarget: self withObject: zero]; } // Then define the loading method anywhere in the same class: - (zero) load image {// Remember to create a new autorovet pool for this thread //  

If you do not have a problem, please provide more details about what is actually happening and what the problem is.

Good luck.


Comments