iOS5 - sharekit for twitter issue

2019-03-16 17:59发布

I am facing keyboard issue in sharekit for iOS5 only.While posting text content to twitter.

enter image description here.I have attached the screenshot for the screen in which I am facing the issues 1.Cancel button is not working 2.Keyboard is not disappearing.

If any one has fixed the issue please help me.

2条回答
ゆ 、 Hurt°
2楼-- · 2019-03-16 18:34

Edit:

Fix Issue #254 - IOS 5 Cancel Button Fix for issue https://github.com/ideashower/ShareKit/issues/254.

In iOS 5, a modally presented view controller has a nil parentViewController, and instead the presenter is presentingViewController. Changed the attempts to dismiss the view using the parentViewController to check for the iOS 5 selector, and used it if available.

So get the latest ShareKit.

Edit 2:

I recommend to use TWTweetComposeViewController if the device has iOS 5.

Class TWTweetComposeViewControllerClass = NSClassFromString(@"TWTweetComposeViewController");

     if (TWTweetComposeViewControllerClass != nil) {
          if([TWTweetComposeViewControllerClass respondsToSelector:@selector(canSendTweet)]) {
              UIViewController *twitterViewController = [[TWTweetComposeViewControllerClass alloc] init];

              [twitterViewController performSelector:@selector(setInitialText:) 
                                          withObject:NSLocalizedString(@"TwitterMessage", @"")];
              [twitterViewController performSelector:@selector(addURL:) 
                                          withObject:url];

               [twitterViewController performSelector:@selector(addImage:) 
                                           withObject:[UIImage imageNamed:@"yourImage.png"]];
                [self.navigationController presentModalViewController:twitterViewController animated:YES];
                [twitterViewController release];
                }
            } else {
                [SHK flushOfflineQueue];
                SHKItem *item = [SHKItem URL:url title:NSLocalizedString(@"TwitterMessage", @"")];

                // Get the ShareKit action sheet
                SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];

                // Display the action sheet
                [actionSheet showInView:[self.view superview].window];
            }

Add in your h file

#if defined(__IPHONE_5_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0
#import <Twitter/Twitter.h>
#import <Accounts/Accounts.h>
#endif

And add the Twitter framework and Accounts as optional Libraries.

查看更多
做自己的国王
3楼-- · 2019-03-16 18:36

Find Alex Terente's Answer in wiki also.

Edit1:

Fix Issue #254 - IOS 5 Cancel Button Fix for issue https://github.com/ideashower/ShareKit/issues/254. In iOS 5, a modally presented view controller has a nil parentViewController, and instead the presenter is presentingViewController. Changed the attempts to dismiss the view using the parentViewController to check for the iOS 5 selector, and used it if available. So get the latest ShareKit.

Edit 2: I recommend to use TWTweetComposeViewController if the device has iOS 5.

Class TWTweetComposeViewControllerClass = NSClassFromString(@"TWTweetComposeViewController");

     if (TWTweetComposeViewControllerClass != nil) {
          if([TWTweetComposeViewControllerClass respondsToSelector:@selector(canSendTweet)]) {
              UIViewController *twitterViewController = [[TWTweetComposeViewControllerClass alloc] init];

              [twitterViewController performSelector:@selector(setInitialText:) 
                                          withObject:NSLocalizedString(@"TwitterMessage", @"")];
              [twitterViewController performSelector:@selector(addURL:) 
                                          withObject:url];

               [twitterViewController performSelector:@selector(addImage:) 
                                           withObject:[UIImage imageNamed:@"yourImage.png"]];
                [self.navigationController presentModalViewController:twitterViewController animated:YES];
                [twitterViewController release];
                }
            } else {
                [SHK flushOfflineQueue];
                SHKItem *item = [SHKItem URL:url title:NSLocalizedString(@"TwitterMessage", @"")];

                // Get the ShareKit action sheet
                SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];

                // Display the action sheet
                [actionSheet showInView:[self.view superview].window];
            }

Add in your h file

#if defined(__IPHONE_5_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_5_0
#import <Twitter/Twitter.h>
#import <Accounts/Accounts.h>
#endif

And add the Twitter framework and Accounts as optional Libraries.

查看更多
登录 后发表回答