I have been looking for a solution for two days now, but I can't find it
My appDelegate is sending the user to mainView, on mainView are 4 buttons in a table, an if statement determines what buttons is being tapped.
In the if statement is a [self presentmodalViewController:exampleScreen animated: NO];
in the exampleScreen .m file is a loadData and is loading stuff from the internet using a JSON parser
The problem is that when the user taps a button, the screen looks frozen, but it loads the data on the mainView and after loading it shows the next screen with the loaded data...
Does anyone knows how to just load the tapped screen and THEN load the data? without the user having to tap another button?
I tried to start animating an activityIndicator in the viewDidLoad, put a sleep(1) after that and after that the [self loadData], but then the sleep is being casted on the mainView....
Try calling loadData in the viewDidAppear method of exampleScreen, so it's called once the view has appeared.
If it's being called in viewDidLoad, then it's being executed once the controller is loaded, which is probably before it's being presented, hence the delay Alternatively you could also do your parsing in a new thread, which should allow the view to be presented without the freezing.
So I tried to put an activityIndicator on the center of the screen in IB in the exampleScreen.xib, but the stupid part is, is that the screen on mainView looks frozen (while it's loading the exampleScreen - the JSON data?), THEN the exampleScreen pops up with the loaded data and the activityindicator shows up like a .5 secs or so and then dissappears because at that time the data is already loaded
It's not at all user friendly if I won't let the user know something is being loaded
lol maybe I'm confused as to how the app is set up. I'm assuming that you have 2 view controllers: mainView and exampleScreen. When you press a button in mainView, it brings up (modally) the exampleScreen. exampleScreen has a method called loadData that is meant to be called when the screen is shown, that parses data & updates exampleView's UI with the data?
Also have you tried calling loadData in a separate thread so it doesn't block the UI (then update the UI on the main thread after parsing is done)?
How are you loading your data? Make sure it isn't using synchronous networking. If it is, that's your problem - synchronous network calls block the entire app. You can't update the UI while they run. Either use async networking or run the sync stuff in a separate thread.
it is a synchronous request in my app!
How do I implement that line of code you posted?
I'm fairly new to xcode!
(you are right about the set-up of the app by the way)
blablablabla cell being filled blabla return cell;
}
How can I get that to work?
Now i just made an empty - (void)test { } and stopped the activityIndicator before [pool release]; and that is working (the indicator looks like it's lasting as long as the loading is supposed to happen..)