Im having trouble with my code, it seems that it never executes right.
I’ve tried many things from UIActivity, Sliders, UITextVieweer etc… but it never changes,
The code is running using Navigation based application from xCode. loadingTview is a Textview,
The problem is, see where loadingTview is, that never works, it always hangs, the user presses a button, and this code is executed. The loadingTview is a Textview saying “loading” with a alpha of 0.4 so basiclly whilst its downloading the image form the website, people know its loading.
I tried views as well but same issue.
How can i progress?
loadingTview.hidden = false;
today = [NSDate date];
dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd-MM-yyyy"];
dateString = [dateFormat stringFromDate:today];
if (PageEntered == @"page1")
{
NSString *url = [NSString stringWithFormat:@"http://www.imagegoeshere.com/%@.jpg",dateString];
imageURL = [NSURL URLWithString:url];
imageData = [NSData dataWithContentsOfURL:url];
image = [UIImage imageWithData:imageData];
FullScreenImage.image = image;
loadingTview.hidden = true;
[navigationController pushViewController:vFullscreen animated:YES];
}
I’m not sure entirely what the problem is but I assume that when you go from view2 to view3 it ‘hangs’ on view2 until the image is loaded before actually opening view3 to show the loading screen, right?
If that’s the case, then what you want to do is load your image in a different thread so that the loading doesn’t block the view3 from showing the loading screen.
Have a look at NSThread (although there are cleaner/better ways to do this).
Basically do this in view3’s controller:
If this is not the problem you have, then please provide more detail as to what is actually happening and what the problem is.
Good luck.