如何在Twitter中分享链接,在iphone设置页面中设置?

时间:2015-03-02 07:54:10

标签: ios objective-c iphone twitter social-framework

我想在twitter上分享一个链接。当时点击twitter按钮分享一个链接。但是第一次点击twitter按钮我要显​​示twitter登录才能在该页面分享,只需要进入iphone设置页面

enter image description here

我的代码是

UIButton *twitterBtn=[[UIButton alloc]initWithFrame:CGRectMake(50,100, 50,  50)];   
[twitterBtn setImage:[UIImage imageNamed:@"Twitter-icon.png"] forState:UIControlStateNormal];
[twitterBtn addTarget:self action:@selector(twitterBtnClicked:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:twitterBtn];

-(void)twitterBtnClicked:(UIButton *)sender
{
    NSString *link=@"http://myWebpage.com";
    TWTRComposer *composer = [[TWTRComposer alloc] init];
    [composer setText:[NSString stringWithFormat:@"%@,%@ ....",      [itemDetailsDict objectForKey:@"name"],link]];

    [composer setImage:[UIImage imageNamed:@"fabric"]];
    [composer showWithCompletion:^(TWTRComposerResult result) {

        if (result == TWTRComposerResultCancelled) {
            NSLog(@"Tweet composition cancelled");
        }

        else {
            NSLog(@"Sending Tweet!");
        }
    }];
}

0 个答案:

没有答案