Iphone 按下UIAlert时在TweetSheet中添加文本
有谁能告诉我,当按下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
- (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
all如果成功返回-(BOOL)setInitialText:(NSString*)text
,如果失败返回YES
NO
- 您可以设置一个完成处理程序,根据用户的决定执行不同的操作(发送tweet/取消)