I'm pretty new at this IOS objective C stuff so hopefully this is an easy one.
I have a rightBarButtonItem that when pressed uses a push segue to move to the next view. However, loading that next view takes a while because it involves a database call. I would like the button to change a UILabel (or otherwise alter the UI) to display a message indicating that it is working.
I've tried doing things in the prepareForSegue method, but those changes only take place right before the view changes, if at all.
How should I accomplish what I'm looking for? Thanks.
I suggest you to MBProgressHUD , which puts a nice modal indicator up. It was dead easy to implement.
Take a look this github demo and use into your project. And i also suggest you For better performing that for process Load Data from DataBase Method in Background using Grand Central Dispatch (GCD) as per your Method:-
for Example in you ViewDidLoad Method:-
[MBProgressHUD showHUDAddedTo:self.view animated:YES]; //Activity Indicator loading
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self LoadDatabae]; //database data fatch method
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.view animated:YES]; //hide that after your Dela Loading finished fromDatabase
});
});
You should display the loader in any of the following method of Secondviewcontroller.(Where database is called).
- (void)viewWillAppear:(BOOL)animated
or
- (void)viewDidAppear:(BOOL)animated
Edit : I was typing to suggest MBProgressHUD . Thanks for Nitin Gohel.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.