내 페이스 북 도우미에서 일부 대리자 메서드를 구현하는보기 컨트롤러가 있습니다. 아이콘과 같은 일부 아이콘 (아이콘)을 두 드릴 때 내 앱이 Facebook 웹 사이트로 이동하여 로그인합니다. 그 후, 그것은 다시 내 애플 리케이션을 전환하지만, 응용 프로그램은 페이 스북 모바일 웹 (사파리) 그래서 다시 한번 쓰는 더 많은 권한이 필요합니다. 확인을 누르면 작업이 완료됩니다. 그러나 내 View Controller의 대리자 메서드는 호출되지 않습니다. 내가 디버그하고 그 시간에 페이 스북 액션이 일어나는 것을 볼 수있다. 변수 "delegate"는 nil이다. 내보기 컨트롤러에는 특별한 것이 있습니다. 백그라운드에서 되돌아 갈 때마다 다른보기 컨트롤러 (스폰서 화면 용)가 표시됩니다. 표시 시간은 약 3 초가 소요되며 스폰서 화면이 사라집니다.
어떻게 위임 메서드를 호출 할 수 있습니까? (BOOL)인가 봐요 withCommentID이 : (있는 NSString *)는 {숨겨진 경우 대리자 메서드가 호출되지 않습니다.
//- check if we are already processed by the loginCallback
if (_loginCallbackInvocation == nil) {
//- create NSInvocation reference to this method
NSInvocation * nsi = [WKTools invocationWithTarget:self selector:_cmd retainArguments:TRUE argumentAddresses:&isLike, &commentID];
//- ensure user has been properly identified and process with authentication if required
[self processLogin:nsi];
}
//- check if user session is valid
if ([[FBSession activeSession] isOpen]) {
if (![self hasPermission:kPublishStream]) {
NSArray *permissions = [NSArray arrayWithObjects: kPublishStream,nil];
dispatch_async(dispatch_get_current_queue(), ^{
[FBSession.activeSession requestNewPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone completionHandler:^(FBSession *session, NSError *error) {
NSString *requestUrl = [NSString stringWithFormat:@"%@%@", commentID,FB_REQUEST_LIKE];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"", MESSAGE_KEY, nil];
//- send request
if (isLike == YES) {
[self requestGraphAPI:requestUrl parameter:params httpMethod:POST_METHOD];
} else {
[self requestGraphAPI:requestUrl parameter:params httpMethod:DELETE_METHOD];
}
}];
});
} else {
NSString *requestUrl = [NSString stringWithFormat:@"%@%@", commentID,FB_REQUEST_LIKE];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"", MESSAGE_KEY, nil];
//- send request
if (isLike == YES) {
[self requestGraphAPI:requestUrl parameter:params httpMethod:POST_METHOD];
} else {
[self requestGraphAPI:requestUrl parameter:params httpMethod:DELETE_METHOD];
}
}
} else {
if ([self isSessionCachedAndLoaded]) {
[FBSession.activeSession openWithCompletionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
if (![self hasPermission:kPublishStream]) {
[[NSUserDefaults standardUserDefaults] synchronize];
NSArray *permissions = [NSArray arrayWithObjects: kPublishStream,nil];
dispatch_async(dispatch_get_current_queue(), ^{
[FBSession.activeSession requestNewPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone completionHandler:^(FBSession *session, NSError *error) {
NSString *requestUrl = [NSString stringWithFormat:@"%@%@", commentID,FB_REQUEST_LIKE];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"", MESSAGE_KEY, nil];
DEBUGLog(@"like comment: %@",requestUrl);
//- send request
if (isLike == YES) {
[self requestGraphAPI:requestUrl parameter:params httpMethod:POST_METHOD];
} else {
[self requestGraphAPI:requestUrl parameter:params httpMethod:DELETE_METHOD];
}
}];
});
} else {
NSString *requestUrl = [NSString stringWithFormat:@"%@%@", commentID,FB_REQUEST_LIKE];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"", MESSAGE_KEY, nil];
//- send request
if (isLike == YES) {
[self requestGraphAPI:requestUrl parameter:params httpMethod:POST_METHOD];
} else {
[self requestGraphAPI:requestUrl parameter:params httpMethod:DELETE_METHOD];
}
}
}];
}
}
}`
을 commentID - (무효) likeCommentFacebook가 가`: 내 페이스 북 도우미에서
[FacebookHelper sharedInstance].fbDelegate = self; [[FacebookHelper sharedInstance] likeCommentFacebook:!isLike withCommentID:message.messageID];
내보기 컨트롤러에서
및 콜백 방법
if (self.fbDelegate && [self.fbDelegate respondsToSelector:@selector(likeCommentDidSuccess:)]) { [self.fbDelegate performSelector:@selector(likeCommentDidSuccess:) withObject:dictionary]; }
우리는 코드를 보지 않고 도울 수 없어요. – trojanfoe
흐름이 많은 메소드와 블록을 통과하기 때문에 코드를 게시하기가 어렵습니다. 내가 발견 한 또 하나의 점은 NSNotificationCenter를 사용하여 내 ViewController의 메서드로 알림을 후크하면 메서드는 반환 된 신호를받을 수 있다는 것입니다. – lenhhoxung
우리가 무엇을 할 수 있는지 잘 모르겠습니다. 델리게이트가 '무 (無)'로가는 이유는 순수한 추측입니다. – trojanfoe