【问题标题】:Is it possible to tweet a photo with the Twitter APIs in iOS5? [duplicate]是否可以在 iOS5 中使用 Twitter API 发布照片? [复制]
【发布时间】:2012-08-21 21:37:33
【问题描述】:

可能重复:
iOS 5 Attach photo to Twitter with Twitter API

一些 Twitter 客户端具有照片推文功能。 iOS 5 Twitter API 是否还包含推特照片的方法?

【问题讨论】:

标签: iphone ios ipad twitter


【解决方案1】:

阅读:TWTweetComposeViewController Class Reference 和 -addImage 属性

【讨论】:

    【解决方案2】:

    【讨论】:

      【解决方案3】:

      当然是的

      if ([[[UIDevice currentDevice] systemVersion] floatValue] > 5.0) {
              // Create the view controller
              TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
      
              // Optional: set an image, url and initial text
              [twitter addImage:[UIImage imageName:@"YourImage.png"]];
              [twitter setInitialText:@"I created this photo Download http://www.twetter.com"];
      
              // Show the controller
              [self presentModalViewController:twitter animated:YES];
      
              // Called when the tweet dialog has been closed
              twitter.completionHandler = ^(TWTweetComposeViewControllerResult result) 
              {
                  NSString *title = @"Tweet Status";
                  NSString *msg; 
      
                  if (result == TWTweetComposeViewControllerResultCancelled)
                      msg = @"Tweet compostion was canceled.";
                  else if (result == TWTweetComposeViewControllerResultDone)
                      msg = @"Tweet composition completed.";
      
                  // Show alert to see how things went...
                  UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
                  [alertView show];
      
                  // Dismiss the controller
                  [self dismissModalViewControllerAnimated:YES];
              };
          }
      

      【讨论】:

      • 太棒了!但是测试类或方法的可用性而不是系统版本不是更好吗?
      • 实际上你必须检查系统版本,因为iOS 5.0及以上版本支持twitter框架,低于版本你必须使用其他一些API,比如上传像twitpic这样的图像
      • 以下是该检查的示例:stackoverflow.com/questions/8248068/…
      • 感谢您与我分享 :)
      • 很高兴我也能提供帮助 :-)
      猜你喜欢
      • 1970-01-01
      • 2012-01-12
      • 2013-06-27
      • 2011-11-28
      • 1970-01-01
      • 2013-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多