1
iOS 5의 트위터를 사용하여 싱글 사인을 구현하려고하는데, settings.app에 계정이없는 경우를 제외하고는 모두 잘 작동합니다. 응용 프로그램이 무한 루프처럼 보이게 잡혔습니다. 콘솔에 메시지가 나타납니다. "twitterd 세션이 중단되어 다시 시작되었습니다."twitter.framework problems
앱에 어떤 도움이 정말 감사합니다 코드
if ([TWTweetComposeViewController canSendTweet])
이 라인에 정지.
////// EDIT ///////// 여기 내 코드 이다 ([TWTweetComposeViewController canSendTweet]) { ACAccountStore accountStore * = [ACAccountStore ALLOC] INIT] 경우; 트위터 계정이 존재하거나없는 경우
// Create an account type that ensures Twitter accounts are retrieved.
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
// Request access from the user to use their Twitter accounts.
[accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
if(granted) {
// Get the list of Twitter accounts.
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
// For the sake of brevity, we'll assume there is only one Twitter account present.
// You would ideally ask the user which account they want to tweet from, if there is more than one Twitter account present.
if ([accountsArray count] > 0)
{
// Grab the initial Twitter account to tweet from.
ACAccount *twitterAccount = [accountsArray objectAtIndex:0];
NSURL *url = [NSURL URLWithString:@"http://api.twitter.com/1/account/verify_credentials.json"];
TWRequest *req = [[TWRequest alloc] initWithURL:url
parameters:nil
requestMethod:TWRequestMethodGET];
// Important: attach the user's Twitter ACAccount object to the request
req.account = twitterAccount;
[req performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse,
NSError *error) {
// If there was an error making the request, display a message to the user
if(error != nil) {
}
// Parse the JSON response
NSError *jsonError = nil;
id resp = [NSJSONSerialization JSONObjectWithData:responseData
options:0
error:&jsonError];
// If there was an error decoding the JSON, display a message to the user
if(jsonError != nil) {
return;
}
}];
}
}
}];
}
고마워요.하지만 전에 시도한 바 있습니다. 내가 계정에서 수업을 사용하면 막히게됩니다. 프레임 워크 ... 코드에서 앱이 ACAccountStore *에서 정지됩니다. [= ACAccountStore alloc] init; – ahmad
전체 코드를 여기에 붙여 넣으십시오 –
시뮬레이터 또는 장치에서 테스트 중이십니까? –