MWPhotoBrowser will not display photo

1.1k Views Asked by At

I'm trying to implement MWPhotoBrowser in my project. I've added all the delegates, but it still will not display the photo.

Here's my didSelectRowAtIndexPath:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
  [self performSegueWithIdentifier:@"MWPhotoBrowserSegue" sender:self] 
}

This is my segue method:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
   if ([segue identifier] isEqualToString:@"MWPhotoBorwserSegue"]) 
   {
       photoBrowser = [[MWPhotoBrowser alloc]initWithDelegate:self]; 
       UINavigationController * nc = [[UINavigationController alloc]initWithRootViewController:photoBrowser]; 

      nc.modalTransitionStyle = UIModalTransitionStyleCrossDisolve; 

      [photos addObject:[MWPhoto photoWithImage:[UIImage imageNamed:@"picasa.jpg"]]; 

      [photoBrowser setCurrentPhotoIndex:0]; 

      [self.navigationController presentViewController:nc animated:YES completion:nil]; 
   }
}

The #ofPhotosInBrowser:

-(NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser 
{
    return self.photos.count;
}

photoAtIndex:

- (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
if (index < self.photos.count)
    return [self.photos objectAtIndex:index];
return nil;
}

Here's what I get after the didSelectRowAtIndexPath: is called: enter image description here Edit for Solution:

MWPhotoBrowser will not display a photo unless you put self.title in the initWithStyle: method. I also forgot to add the viewWillDisappear and viewWillAppear

2

There are 2 best solutions below

0
On

I think u need to call reload data on it. Check Mwphotobrowser.h for proper way to do it.

0
On

try this [[NSOperationQueue mainQueue] addOperationWithBlock:^{ [self presentViewController:yourNewNavigationController animated:YES completion:nil]; }];