Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 按下UIAlert时在TweetSheet中添加文本_Iphone_Ios_Ios5_Twitter - Fatal编程技术网

Iphone 按下UIAlert时在TweetSheet中添加文本

Iphone 按下UIAlert时在TweetSheet中添加文本,iphone,ios,ios5,twitter,Iphone,Ios,Ios5,Twitter,有谁能告诉我,当按下UIAlert标题按钮时,如何在TweetSheet中添加文本 目前我正在使用这段代码来实现它,但到目前为止失败了 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { NSString *title = [alertView buttonTitleAtIndex:buttonIndex]; TWTweetComposeViewCont

有谁能告诉我,当按下UIAlert标题按钮时,如何在TweetSheet中添加文本

目前我正在使用这段代码来实现它,但到目前为止失败了

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

    TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];

    if ([title isEqualToString:@"Add custom text"]) {
        UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"Add a template" message:nil delegate:self cancelButtonTitle:@"Hi it was nice meeting you" otherButtonTitles:nil, nil];
        [alert show];
        [alert release];
    }

    if ([title isEqualToString:@"Hi it was nice meeting you"]) {
        [tweetSheet setInitialText:@"hey it was nice meeting you"];
    }

}

谁能告诉我这里怎么了

您没有展示您的
tweetcomposeviewcontroller
您只需添加以下内容即可:

[self presentModalViewController:tweetSheet animated:YES];
我猜这段代码只用于一个简单的测试tweet。 对于一个严肃的项目,您应该始终:

  • 在尝试显示
    TWTweetComposeViewController

  • 如果不确定要设置的属性(文本、图像、url),则需要检查添加它们是否成功:
    -(BOOL)addImage:(UIImage*)image
    -(BOOL)addURL:(NSURL*)url
    -(BOOL)setInitialText:(NSString*)text
    all如果成功返回
    YES
    ,如果失败返回
    NO

  • 您可以设置一个完成处理程序,根据用户的决定执行不同的操作(发送tweet/取消)

2011年关于Twitter集成的WWDC会议非常简单和详细,如果需要更多信息,您应该观看并阅读