MWPhotoBrowser不会显示照片

时间:2013-11-06 01:28:46

标签: ios objective-c nsmutablearray mwphotobrowser

我正在尝试在我的项目中实现MWPhotoBrowser。我添加了所有代表,但仍然无法显示照片。

这是我的didSelectRowAtIndexPath:

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

这是我的segue方法:

- (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]; 
   }
}

#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;
}

这是在调用didSelectRowAtIndexPath:后得到的: enter image description here 编辑解决方案:

除非将self.title放在initWithStyle:方法中,否则MWPhotoBrowser不会显示照片。我也忘了添加viewWillDisappear和viewWillAppear

2 个答案:

答案 0 :(得分:0)

我认为你需要在其上调用重载数据。检查Mwphotobrowser.h以获得正确的方法。

答案 1 :(得分:0)

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