【问题标题】:MWPhotoBrowser will not display photoMWPhotoBrowser 不会显示照片
【发布时间】:2013-11-06 01:28:46
【问题描述】:

我正在尝试在我的项目中实现 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: 被调用后得到的: 编辑解决方案:

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

【问题讨论】:

    标签: ios objective-c nsmutablearray mwphotobrowser


    【解决方案1】:

    我认为你需要调用重新加载数据。检查 Mwphotobrowser.h 以了解正确的方法。

    【讨论】:

      【解决方案2】:

      试试这个 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ [self presentViewController:yourNewNavigationController 动画:YES 完成:nil]; }];

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-01-04
        • 1970-01-01
        • 2015-08-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-12-29
        • 1970-01-01
        相关资源
        最近更新 更多