iOS5 - sharekit for twitter issue

爷,独闯天下 提交于 2019-12-03 14:53:28

问题


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

.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.


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/8599944/ios5-sharekit-for-twitter-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!