1

I have in my app a facebook share button, a tweet button. My app supports to IOS 5.1. So for twitter there is no problem. But how should I work with the facebook share button.

If the IOS device that is running the app is using IOS6 I want to use the new way, like you can see over here

But when the app is running on previous IOS devices. I want to use the old fashion way.

Can anybody help me?

Kind regards

4

3 回答 3

6

If you're wondering if SLComposeViewController supports Facebook, check isAvailableForServiceType, e.g.

if ([SLComposeViewController class]) {
    // once you know that they have iOS 6 or higher
    // check if the account is setup
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
    {
        // now we know we have a facebook account configure and logged in
    }
} else {
    // You don't have iOS 6 or higher
}

It's generally better to use API (or class or NSClassFromString for weakly linked classes, or respondsToSelector, if a class has methods that were added in later versions of iOS) rather than checking for version of iOS. For more information, see Supporting Multiple Versions of iOS section of the iOS App Programming Guide.

于 2012-10-18T12:36:53.080 回答
1

You can use the following code:

if([[[UIDevice currentDevice] systemVersion] intValue] == 6)
{
 // your code for iOS 6
}
else
{
 // your code for other iOS
}
于 2012-10-18T12:37:09.337 回答
1

The steps are: First weak link the social framework (make it optional)

Next check to see if the app can you use SLComposeViewController and then check to see if the user has set up their Facebook account

if(NSClassFromString(@"SLComposeViewController") != nil)
{
  if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]])
  {
   //Add your SLComposeViewController code
  }
}
于 2012-10-18T12:44:10.930 回答