简体   繁体   English

FBProfilePictureView没有显示图像

[英]FBProfilePictureView is not showing image

I'm having the same problem I saw some people have with the FBProfilePictureView not showing the photo. 我遇到了同样的问题,我看到有些人的FBProfilePictureView没有显示照片。 I've already seen this question and I've added 我已经看到了这个问题,并添加了

[FBProfilePictureView class]; [FBProfilePictureView类];

to my first line of the app delegate method didFinishLaunching but that did not solve. 到我的应用程序委托方法的第一行didFinishLaunching,但这并没有解决。

Sometimes it loads all images, sometimes it loads most of them and sometimes only a few images. 有时加载所有图像,有时加载大多数图像,有时仅加载少量图像。

I create the FBProfilePictureView programmatically doing: 我以编程方式创建FBProfilePictureView:

FBProfilePictureView *friendProfilePic = [[FBProfilePictureView alloc] init]; FBProfilePictureView * friendProfilePic = [[FBProfilePictureView alloc] init];

friendProfilePic.profileID = friendID; friendProfilePic.profileID = friendID; //friendID is a NSString I've created before // friendID是我之前创建的NSString

friendProfilePic.frame = CGRectMake(xPos, yPos, width, height); friendProfilePic.frame = CGRectMake(xPos,yPos,宽度,高度);

Does anyone know what might be happening? 有人知道会发生什么吗?

Note: I didn't want to use -ObjC linker flag because it will raise my app size 注意:我不想使用-ObjC链接器标志,因为它会增加我的应用程序大小

Note2: I can't comment on questions so I had to make another one. 注意2:我无法对问题发表评论,因此我不得不再做一个问题。

Thanks 谢谢

If it is loading some images then it is not related to the ObjC linker flag. 如果它正在加载某些图像,则它与ObjC链接器标志无关。 It is likely some of the requests are failing. 某些请求很可能失败。 I created a replacement for FBProfilePictureView that reports errors. 我为报告错误的FBProfilePictureView创建了替换项。 Add it to your project and change your code to: 将其添加到您的项目并将代码更改为:

DBFBProfilePictureView *friendProfilePic = [[DBFBProfilePictureView alloc] initWithFrame:CGRectMake(xPos, yPos, width, height)];
friendProfilePic.profileID = friendID;
friendProfilePic.completionHandler = ^(DBFBProfilePictureView* view, NSError* error){
        if(error) {
            view.showEmptyImage = YES;
            view.profileID = nil;
            NSLog(@"Loading profile picture failed with error: %@", error);
        } 
    };

and you will see any errors logged to the console. 并且您将看到任何错误记录到控制台。

Did you add the ProfilePic to your view? 您是否将ProfilePic添加到视图?

Get the main view, and add the profilepic as a subview to it. 获取主视图,然后将profilepic作为子视图添加到它。

[myMainView addSubView: friendProfilePic]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM