I am using sharekit in my app for posting text to twitter. The thing is i need to pop to the root view controller (main controller) when the user clicks the send to twitter button in modal view.how to do this?
2 Answers
If you're running iOS 5 or above you can use TWTweetComposer to send tweets rather than ShareKit or the Social framework in iOS 6.
But if you want to use sharekit you'll need a delegate for your modalView.
You need to create a protocol. In the modal view header use something like
@protocol TwitterModalDelegate
-(void)closeModal;
@end
Then implement an id that conforms to that protocol as a property or ivar (usually called delegate)
@property (nonatomic, assign) id<TwitterModalDelegate> delegate
Now in your view controller presenting the modal tell it that it uses the protocol.
@interface YourViewControllerName : UIViewController <TwitterModalDelegate>
You will need to import the modal view header into your ViewController header.
You now control what happens when the modal view closes.
-(void)closeModal
{
[self dismissViewControllerAnimated:YES completion:^
{
[self.navigationController popToRootViewControllerAnimated:YES ];
}];
}
So in your modal view when you confirm that the tweet has been sent you can simply call
[self.delegate closeModal];
Remember when creating an instance of the modal view to:
YourModalView* modalView = [YourModalView alloc]init];
modalView.delegate = self
[self presentViewController:modalView animated:YES completion:nil];

- 884
- 8
- 14
-
can u suggest me how to do it in share kit..because i tried but its not working. i may have done mistakes.. help me – Gowtham Nov 03 '12 at 15:56
set your sharekit instance delegate to your current controller and implement (void)sharerFinishedSending:(SHKSharer *)sharer; this is sharekit delegate method to handle finished request

- 937
- 5
- 8