0

I searched for many times but i din't find i have table view with some cells when i clicked the cell it is navigating to another view while navigating i need to put some time delay and in that time delay a progress bar has to load

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *str_date=[data objectAtIndex:indexPath.row];
    [[NSUserDefaults standardUserDefaults] setObject:str_date forKey:@"str_date"];

    NSString *str_time=[time objectAtIndex:indexPath.row];
    [[NSUserDefaults standardUserDefaults] setObject:str_time forKey:@"str_time"];

    NSString *str_image=[images objectAtIndex:indexPath.row];
    [[NSUserDefaults standardUserDefaults] setObject:str_image forKey:@"str_image"];

    detailview *dv=[[detailview alloc]init];
    [self presentViewController:dv animated:YES completion:nil];
}
alexgophermix
  • 4,189
  • 5
  • 32
  • 59
rakesh
  • 73
  • 3
  • 12

2 Answers2

1

I'm not 100% sure what you're asking but if you need something that displays progress while loading, or even just blocks user interaction with a spinner until a load is complete you should look into MBProgressHud:

https://github.com/jdg/MBProgressHUD

The correct way to use this library (as taken from the GitHub page) is to initalize it on the main thread and then break off your operation onto a new thread like so:

[MBProgressHUD showHUDAddedTo:self.view animated:YES];
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
    // Do something...
    dispatch_async(dispatch_get_main_queue(), ^{
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    });
});

In your case because you need MBProgressHUD for view transitions, you won't want to use self.view as can cause errors when the new view is pushed overtop. Instead look into ways of displaying MBProgressHUD globally (persistent across view transitions). There's one example of how to do this here.

Community
  • 1
  • 1
alexgophermix
  • 4,189
  • 5
  • 32
  • 59
  • the code i have given is for selected row and in that iam going to "detail view" while going to detail view i have to show some progress bar – rakesh Nov 20 '13 at 07:05
  • You'll have to display the HUD before leaving the view AKA in your `didSelectRowAtIndexPath:(NSIndexPath *)indexPath` method and then hide it in what you call the "detail view", likely within `viewWillAppear` or `viewDidAppear` – alexgophermix Nov 20 '13 at 07:12
0

Add the following files into your project.

And Use the following line to load Progress bar

[HUD showUIBlockingIndicatorWithText:@"Loading"];

and hide the progress bar wherever you want with the following line,

[HUD hideUIBlockingIndicator];

Get HUD files from here,

http://www.megafileupload.com/en/file/470802/MBProgressHUD-h.html

http://www.megafileupload.com/en/file/470804/MBProgressHUD-m.html

http://www.megafileupload.com/en/file/470800/HUD-h.html

http://www.megafileupload.com/en/file/470801/HUD-m.html

Hope, it helps you.

sathiamoorthy
  • 1,488
  • 1
  • 13
  • 23