2012-04-04 7 views
1

iOS 5의 내 앱에서 Twitter 앱을 열려고하는데 열리지 않습니다. 어떤 도움을 주시면 감사하겠습니다. 아래 코드를 사용했습니다.iOS 5 앱에서 Twitter 앱을 엽니 다.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=TWITTER"]]; 

도와주세요. 미리 감사드립니다.

답변

0

Twitter 앱을 시작 하시겠습니까, 아니면 앱에서 트윗을 보내시겠습니까? 위의 코드가 설정 앱에서 Launch Twitters 환경 설정에 있다고 믿습니다 ... 또한 5.1에서 허용되지 않은 것으로 믿습니다.

앱에 Twitter 통합을 추가하려는 경우 Apple에서 훌륭한 샘플 코드를 제공합니다.

이제이 샘플 코드를 다운로드하고 (CanTweetStatus 확인과 같은) 트윗을 보내는 데 필요한 다른 항목을 확인하는 것이 좋습니다. 이 게시물에 트윗을 보내는 방법에 대한 기본 아이디어. 행운

https://developer.apple.com/library/ios/#samplecode/Tweeting/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011191

- (IBAction)sendCustomTweet:(id)sender { 
    // Create an account store object. 
    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]; 

       // Create a request, which in this example, posts a tweet to the user's timeline. 
       // This example uses version 1 of the Twitter API. 
       // This may need to be changed to whichever version is currently appropriate. 
       TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"http://api.twitter.com/1/statuses/update.json"] parameters:[NSDictionary dictionaryWithObject:@"Hello. This is a tweet." forKey:@"status"] requestMethod:TWRequestMethodPOST]; 

       // Set the account used to post the tweet. 
       [postRequest setAccount:twitterAccount]; 

       // Perform the request created above and create a handler block to handle the response. 
       [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) { 
        NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]]; 
        [self performSelectorOnMainThread:@selector(displayText:) withObject:output waitUntilDone:NO]; 
       }]; 
      } 
     } 
    }]; 
} 

좋은!

4

그냥 실제 트위터 앱을 실행하려는 경우 다음 코드는

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"twitter://"]]; 
+0

트위터 응용 프로그램이 설정 트위터되지 여는이다. – PJR

+0

앱에서 환경 설정을 열 수 없습니다. – Otium

관련 문제