I'v implemented tableView with searchBar (used searchDispalyController) which user can enter a search term and table view shows which stories contains this search term . after tapping on the cell, a pageBasedView will push to the view which contains text and user can curl pages. (the app is a book).
the heavy task is on a method that truncate the a huge text into small parts and add them to an array.
so when user taps on a cell the burden of truncating is transferred to pageBasedViewController. it takes about a few seconds to truncating be completed and pages be ready for navigating.
in these few seconds I want to show an activityIndicator which I used MBProgressHud.
the problem rise here when tapping on a cell, the activityIndicator won't appear until the new page is going to the view.
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
//the heavy task
[self truncate:contentString];
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.view animated:YES];
});
});
here is an screenShot which shows the flow of app:
Im amazed why I can't see the ActivityIndicator! after removing this code:
[MBProgressHUD hideHUDForView:self.view animated:YES];
swiping back to masterViewController and again tapping on the cell process take a few second and surprisingly will see the indicator is working! but Im amazed why for the first time it doesn't work?
from noon until midnight Im working on it. but no solution!
I have uploaded sample app download from here: (67 KB)
http://www.mediafire.com/download/decvu7uig9r6v1a/pageBasedApp.zip
solved. I did this way:
and after recieving semaphore: . . .