首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >按钮中使用的MWPhotoBrowser (Xcode)

按钮中使用的MWPhotoBrowser (Xcode)
EN

Stack Overflow用户
提问于 2012-01-18 00:10:48
回答 1查看 475关注 0票数 0

我正在尝试将您的实现作为一个名为‘Gallery’的按钮实现到我的项目中,但在尝试运行该项目时收到错误。

我的实现文件如下所示。

代码语言:javascript
复制
-(IBAction) gallery{


  NSMutableArray *photos = [[NSMutableArray alloc] init];

MWPhoto *photo;

{

    photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"fans1" ofType:@"jpg"]];

    photo.caption = @"My fans 1";

    [photos addObject:photo];

    photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"fans2" ofType:@"jpg"]];

    photo.caption = @"My fans 2";

    [photos addObject:photo];

    photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"fans3" ofType:@"jpg"]];

    photo.caption = @"Fans3";

    [photos addObject:photo];

    photo = [MWPhoto photoWithFilePath:[[NSBundle mainBundle] pathForResource:@"fans4" ofType:@"jpg"]];

    photo.caption = @"Fans4";

    [photos addObject:photo];


}






  self.photos = photos;



     // Create browser

  MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];

browser.displayActionButton = YES;

  //browser.wantsFullScreenLayout = NO;

  //[browser setInitialPageIndex:2];



  // Show

  if (_segmentedControl.selectedSegmentIndex == 0) {

// Push

[self.navigationController pushViewController:browser animated:YES];

  } else {

// Modal

UINavigationController *nc = [[UINavigationController alloc]              initWithRootViewController:browser];

   nc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

[self presentModalViewController:nc animated:YES];

   }

  }

  #pragma mark - MWPhotoBrowserDelegate

  - (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {

   return _photos.count;

     }



  - (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:   (NSUInteger)index {

      if (index < _photos.count)

       return [_photos objectAtIndex:index];

   return nil;

  }

当我运行项目,但图片库没有显示。我是ioS development.If的新手,如果您能告诉我正确的方向,我将不胜感激。主要目标是在用户触摸gallery按钮时显示图片库。

我复制并编辑了MWPhotoBrowser演示项目文件中的代码,我没有收到任何错误,但一旦触摸按钮,我就无法让图库出现。(顺便说一下,我给按钮分配了IBACTION )。如果有其他源代码或替代框架我可以使用,请告知。谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-02 08:18:21

一些想法:

1)尝试使用'initWithPhotos‘。

2)在推流的地方设置断点,检查是否调用了推流。

3)调试时检查navigationController不为空(0x0)。

4)记得释放'browser‘。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8897897

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档