ios - 无法在 iOS 中将图像 url 分配给 MWPhoto

标签 ios objective-c xcode mwphotobrowser

在我的应用程序中使用了 https://github.com/mwaterfall/MWPhotoBrowser图书馆 .. 但我无法分配图片网址 我如何分配图片网址。请解决我的问题 请检查我的代码:

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

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


- (void)viewDidLoad
{
    [super viewDidLoad];
    NSMutableArray *photos = [[NSMutableArray alloc] init];

   // photos=[[NSMutableArray alloc]initWithObjects:@"1.jpg",@"2.jpg",@"3.png", nil];
    photos=[[NSMutableArray alloc]initWithObjects:@"http://www.google.co.in/imgres?imgurl=https://alaskabibleteacher.files.wordpress.com/2014/09/apple-tree.jpg&imgrefurl=http://brokenbelievers.com/2014/09/19/the-apple-tree/&h=606&w=808&tbnid=uY1OY_HyQ8hE1M:&docid=vKsOHUHBZ2CVFM&ei=1mXuVcu1O8rbuQTW_7Z4&tbm=isch&ved=0CDEQMygBMAFqFQoTCMv4zcvO5scCFcptjgod1r8NDw",@"http://www.apple.com/ipad/home/images/social/og.jpg?201508031746", nil];
    for (int i = 0; i < photos.count; i++)
    {
        [photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:photos[i]]]];
    }
    _photos = photos;
    MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
    UINavigationController *nc = [[UINavigationController alloc]     initWithRootViewController:browser];
    [browser showNextPhotoAnimated:YES];
    [browser showPreviousPhotoAnimated:YES];
    [self presentViewController:nc animated:YES completion:nil];

}

我更新了我的代码和错误... 我收到一个错误: [MWPhoto 长度]:发送到实例 0x7febf97f4740 的无法识别的选择器 2015-09-08 10:43:16.231 沙龙 [3926:66068] *** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[MWPhoto 长度]:无法识别的选择器发送到实例 0x7febf97f4740”

最佳答案

在您的 Other linker Flags 中添加 -ObjC-all_load 并检查,如果已经可用,则在build设置中删除上述标志。

附加reference

关于ios - 无法在 iOS 中将图像 url 分配给 MWPhoto,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32449363/

相关文章:

objective-c - UINavigationController 右栏按钮项目未显示

iphone - 为 iPhone 应用程序编译错误 : "error:expected ' )' before ' ;' token"

ios - Xcode 错误 : "Failed to save .xcodeproj"

ios - 如何将 Firebase 中的 child 的名字设置为来自文本字段的用户输入?

ios - 产生处理器时间

ios - 有深度的摇摆动画

ios - Segue 标识符未显示在属性检查器中

SwiftUI 可观察对象未观察到

Xcode 7 beta swift 应用程序在运行时崩溃并出现 EXC_BAD_ACCESS 错误

javascript - iOS 从 UIWebView 检索 javascript 变量