Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MJSocialComposeViewController class allows to use iOS 6.0 SLComposeViewController class in iOS 5.0.

NotificationsYou must be signed in to change notification settings

dmitrikozlov/MJSocialComposeViewController

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

Apple introduced support for Twitter in iOS 5.0. iOS 6.0 replaced the interface with a new onethat allowed posting to three social networks: Twitter, Facebook and SinaWeibo.The new interface is very similar to the old one; still, they are different and applicationstargeting both versions 5 and 6 have to program interactions with social networks twice.

MJSocialComposeViewController class elegantly solves this problem. It uses Objective C powerfulmessage forwarding mechanism and implements a proxy class exposing SLComposeViewController interfaceto a caller. That allows to program to iOS 6.0 SDK interface while targeting earlier runtime versions of iOS.

MJSocialComposeViewController class illustrates a proxy class implementationin Objective C language and may serve as a tutorial. Message forwarding is not documented verywell. This small project may be helpful in filling in this gap.

MJSocialComposeViewController doesn't add functionality. It uses SLComposeViewController in iOS 6 andfalls back to TWTweetComposeViewController on iOS 5. It doesn't provide Facebook or SinaWeibo integrationfor iOS 5.

MJSocialComposeViewController is not intrusive when there is no need for that. If you compile your projectfor iOS version 6.0 and above then MJSocialComposeViewController will cease to exist (literally). Your projectwill use iOS 6.0 native SLComposeViewController class. You won't need to change anything in your code to dropsupport of older iOS versions.

How to use

Add files from the folder MJSocialComposer to your project.Add Social.framework and Twitter.framework into the project and mark them as Optional.Set Deployment Target to 5.0. You may set it to a smaller number, but you won't get any functionality fromMJSocialComposeViewController class then. Be warned: lower than 5.0 versions haven't been tested, you areon your own.Import header "MJSocialComposeViewController.h" header in your source and start coding.

See the implementation of SocialComposer.xcodeproj as an example, namely MJViewController class.

A glitch

Facebook implementation in iOS 6.0 (that is SLComposeViewController class) doesn't like the proxy. A call to

[aViewController presentViewController:proxyComposer animated:NO completion:nil];

doesn't work with Facebook ('proxyComposer' is a pointer to MJSocialComposeViewController object).The call works correctly with Twitter or SinaWeibo services as well as with a plain UIViewController object(if proxyComposer object is a proxy of a UIViewController object).

A workaround is to pass an actual object:[aViewController presentViewController:proxyComposer.actualController animated:NO completion:nil];

References

http://www.mikeash.com/pyblog/friday-qa-2009-03-27-objective-c-message-forwarding.html

About

MJSocialComposeViewController class allows to use iOS 6.0 SLComposeViewController class in iOS 5.0.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp