2012-10-01 39 views
37

Mã của tôi đang hoạt động như dự kiến ​​mà tôi cần phải loại bỏ thông báo cảnh báo này. TWTeetComposeViewController không được chấp nhận trong IOS6. Bất kỳ sự thay thế nào cho bộ điều khiển xem tích hợp này trong ios6?TWTweetComposeViewController không được chấp nhận trong IOS6

Đây là mã mẫu của tôi.

if ([TWTweetComposeViewController canSendTweet]) { 
    // Initialize Tweet Compose View Controller 
    TWTweetComposeViewController *vc = [[TWTweetComposeViewController alloc] init]; 
    // Settin The Initial Text 
    [vc setInitialText:@"This tweet was sent using the new Twitter framework available in iOS 5."]; 
    // Adding an Image 
    UIImage *image = [UIImage imageNamed:@"sample.jpg"]; 
    [vc addImage:image]; 
    // Adding a URL 
    NSURL *url = [NSURL URLWithString:@"http://mobile.tutsplus.com"]; 
    [vc addURL:url]; 
    // Setting a Completing Handler 
    [vc setCompletionHandler:^(TWTweetComposeViewControllerResult result) { 
     [self dismissModalViewControllerAnimated:YES]; 
    }]; 
    // Display Tweet Compose View Controller Modally 
    [self presentViewController:vc animated:YES completion:nil]; 
} else { 
    // Show Alert View When The Application Cannot Send Tweets 
    NSString *message = @"The application cannot send a tweet at the moment. This is because it cannot reach Twitter or you don't have a Twitter account associated with this device."; 
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops" message:message delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; 
    [alertView show]; 
} 
+0

cậu thấy rằng TWTeetComposeViewController ở đâu ?? http://developer.apple.com/library/ios/#documentation/Twitter/Reference/TWTweetSheetViewControllerClassRef/Reference/Reference.html – Martin

Trả lời

68

Như vậy là một số thay đổi với việc sử dụng mạng xã hội giữa iOS 5 & iOS 6.
1. Về thư viện: trong iOS 6 chúng tôi sử dụng khuôn khổ xã hội thay vì Twitter khung.
2. Chúng tôi sử dụng SLComposeViewController thay vì TWTweetComposeViewController.
3.Please so sánh một số api với đoạn mã sau:

if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { 

     SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; 

     SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){ 
      if (result == SLComposeViewControllerResultCancelled) { 

       NSLog(@"Cancelled"); 

      } else 

      { 
       NSLog(@"Done"); 
      } 

      [controller dismissViewControllerAnimated:YES completion:Nil]; 
     }; 
     controller.completionHandler =myBlock; 

     //Adding the Text to the facebook post value from iOS 
     [controller setInitialText:@"Test Post from mobile.safilsunny.com"]; 

     //Adding the URL to the facebook post value from iOS 

     [controller addURL:[NSURL URLWithString:@"http://www.mobile.safilsunny.com"]]; 

     //Adding the Image to the facebook post value from iOS 

     [controller addImage:[UIImage imageNamed:@"fb.png"]]; 

     [self presentViewController:controller animated:YES completion:Nil]; 

    } 
    else{ 
     NSLog(@"UnAvailable"); 
    } 

Có chỉ là một sự khác biệt nhỏ, nhưng họ đang tuyệt vời hơn.

ƯU ĐÃI: - Mẹo safilsunny: http://www.mobile.safilsunny.com/integrating-facebook-ios-6/

Cảm ơn,

27

Vâng, bạn đang phải sử dụng Social Framework trên iOS 6. Đây là nhờ vào việc tích hợp Facebook hiện có mặt trên iOS. Bạn sẽ có thể sử dụng Twitter và Facebook từ đó.

Các vấn đề liên quan