Reputation: 5377
As a newbie i wanted to try out Facebook and Twitter Post using objective-c
So i added 2 buttons, added actions to it, also added social framework. When i run the code and click on Tweet or Facebook Buttons nothing happens, am i missing something.I am testing it on Simulator, does that make any difference.
Here is my header file SocialSharingViewController.h
#import <UIKit/UIKit.h>
@interface SocialSharingViewController : UIViewController
- (IBAction)postToTwitter:(id)sender;
- (IBAction)postToFacebook:(id)sender;
@end
Here is my .m file SocialSharingViewController.m
#import "SocialSharingViewController.h"
#import <Social/Social.h>
@interface SocialSharingViewController ()
@end
@implementation SocialSharingViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)postToTwitter:(id)sender {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
SLComposeViewController *tweetSheet = [SLComposeViewController
composeViewControllerForServiceType:SLServiceTypeTwitter];
[tweetSheet setInitialText:@"Great fun to learn iOS programming"];
[self presentViewController:tweetSheet animated:YES completion:nil];
}
}
- (IBAction)postToFacebook:(id)sender {
NSLog(@"clicked facebook button");
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
[controller setInitialText:@"First post from my iPhone app"];
[self presentViewController:controller animated:YES completion:Nil];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Upvotes: 0
Views: 71
Reputation: 1491
A few things come to mind:
IBAction
methods in your code?-isAvailableForServiceType:
legitimately returning NO
, preventing them from showing?Upvotes: 1