Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Jayden Spring
Jayden Spring
8,625 Points

MBProgressHUD Ribbit Extra Credit

Hi,

I am trying to implement MBProgressHUD to display a message that the picture/video has been sent after the user clicks send in the Camera view. I have hit a brick wall as to how I am going to call the HUD to be displayed. Since there is no segue between the two views and they are changing through setting the tab index I have tried creating an instance method in the InboxViewController and call it before the tab is changed in the CameraView Controller.

//InboxViewController.h
@interface InboxViewController : UITableViewController
-(void)uploadComplete;
@end
//InboxViewController.m
-(void)uploadComplete{
  hud = [MBProgressHUD showHUDAddedTo:self.tableView animated:YES];
  hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]];
  hud.mode = MBProgressHUDModeCustomView;
  hud.labelText = @"Sent!";
  [hud show:YES];
  [hud hide:YES afterDelay:3];
}
//CameraViewController.m
- (IBAction)send:(id)sender {
  if(self.image == nil && [self.videoFilePath length] == 0){
    //Image prop is nil & video is empty - present alert
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Try Again!" message:@"Please capture or select a photo or video to share" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
    [alert show];
    [self presentViewController:self.imagePicker animated:NO completion:nil];
  }else{
    // [self uploadMessage];
    InboxViewController *iv = [[InboxViewController alloc]init];
    [iv uploadComplete];
    [self.tabBarController setSelectedIndex:0];

  }
}

I have also tried creating a boolean property in the InboxVC and setting it before the change in the CameraVC. However when the view changes the boolean is reset back to NO.

If anyone could help that would be great, would love to get my head around this.

Thanks!

2 Answers

Jayden Spring
Jayden Spring
8,625 Points

Can anyone help? :) Thanks!