簡體   English   中英

由於未捕獲的異常“ NSInvalidArgumentException”而終止應用程序,原因:“-[FBSDKProfilePictureView CGImage]:

[英]Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FBSDKProfilePictureView CGImage]:

在.h文件中聲明以進行Facebook sdk集成

@property (weak, nonatomic) IBOutlet FBSDKProfilePictureView *profilePicture;

在.m文件中聲明

self.profilePicture.profileID = [ result objectForKey:@"id"];
 UIImage *img=self.profilePicture;

給出錯誤

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FBSDKProfilePictureView CGImage]: unrecognized selector sent to instance 0x7fdd5a5651e0'
*** First throw call stack:(
0   CoreFoundation                      0x0000000106366a75 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x0000000105ffabb7 objc_exception_throw + 45
2   CoreFoundation                      0x000000010636dd1d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3   CoreFoundation                      0x00000001062c59dc ___forwarding___ + 988
4   CoreFoundation                      0x00000001062c5578 _CF_forwarding_prep_0 + 120
5   UIKit                               0x00000001048c5732 UIImagePNGRepresentation + 33
6   SmartCookieProgram                  0x0000000103bd0770 __47-[LoginViewController loginViewFetchedUserInfo]_block_invoke + 2880
7   SmartCookieProgram                  0x0000000103c0b903 -[FBSDKGraphRequestMetadata invokeCompletionHandlerForConnection:withResults:error:] + 146
8   SmartCookieProgram                  0x0000000103c11c6d __64-[FBSDKGraphRequestConnection processResultBody:error:metadata:]_block_invoke370 + 142
9   SmartCookieProgram                  0x0000000103c11a02 -[FBSDKGraphRequestConnection processResultBody:error:metadata:] + 1046
10  SmartCookieProgram                  0x0000000103c114d0 __64-[FBSDKGraphRequestConnection completeWithResults:networkError:]_block_invoke + 428
11  CoreFoundation                      0x000000010629e782 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 114
12  CoreFoundation                      0x000000010629dedc -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 300
13  SmartCookieProgram                  0x0000000103c11287 -[FBSDKGraphRequestConnection completeWithResults:networkError:] + 670
14  SmartCookieProgram                  0x0000000103c10574 -[FBSDKGraphRequestConnection completeFBSDKURLConnectionWithResponse:data:networkError:] + 669
15  SmartCookieProgram                  0x0000000103c0eca2 __36-[FBSDKGraphRequestConnection start]_block_invoke_2 + 72
16  SmartCookieProgram                  0x0000000103c0c034 -[FBSDKURLConnection invokeHandler:error:response:responseData:] + 85
17  SmartCookieProgram                  0x0000000103c0bfa9 -[FBSDKURLConnection logAndInvokeHandler:response:responseData:] + 395
18  SmartCookieProgram                  0x0000000103c0c2fa -[FBSDKURLConnection connectionDidFinishLoading:] + 135
19  CFNetwork                           0x0000000108e3b98c __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 69
20  CFNetwork                           0x0000000108e3b930 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 199
21  CFNetwork                           0x0000000108e3ba97 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 48
22  CFNetwork                           0x0000000108d0b937 ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 107
23  CFNetwork                           0x0000000108dd8a31 ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 273
24  CFNetwork                           0x0000000108cf6d16 _ZN19RunloopBlockContext13_invoke_blockEPKvPv + 72
25  CoreFoundation                      0x000000010626eb44 CFArrayApplyFunction + 68
26  CFNetwork                           0x0000000108cf6bd7 _ZN19RunloopBlockContext7performEv + 133
27  CFNetwork                           0x0000000108cf6a16 _ZN17MultiplexerSource7performEv + 256
28  CFNetwork                           0x0000000108cf682c _ZN17MultiplexerSource8_performEPv + 72
29  CoreFoundation                      0x000000010629bc91 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
30  CoreFoundation                      0x0000000106291b5d __CFRunLoopDoSources0 + 269
31  CoreFoundation                      0x0000000106291194 __CFRunLoopRun + 868
32  CoreFoundation                      0x0000000106290bc6 CFRunLoopRunSpecific + 470
33  GraphicsServices                    0x0000000107e02a58 GSEventRunModal + 161
34  UIKit                               0x0000000104892580 UIApplicationMain + 1282
35  SmartCookieProgram                  0x0000000103bce9c3 main + 115
36  libdyld.dylib                       0x0000000107648145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

請提供錯誤的解決方案,並且還想知道如何使用FBSDKGraphRequestFBSDKGraphRequestConnection獲取用戶位置

FBSDKProfilePictureView是一種UIView類,而不是Image。

在xib或情節提要板上添加UIImageVIew並創建相同的IBOutlet。

@屬性(弱,非原子)IBOutlet UIImageView * imageView;

使用以下代碼:

self.profilePicture = [[FBSDKProfilePictureView alloc] initWithFrame:_imageView.frame];
[_profilePicture setProfileID: result[@"id"]];
[self.view addSubview:_profilePicture];

會的!!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM