首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >我怎么才能解雇UIAlertView呢?

我怎么才能解雇UIAlertView呢?
EN

Stack Overflow用户
提问于 2011-02-07 02:32:53
回答 2查看 26.7K关注 0票数 19

我怎么才能解雇UIAlertView呢?此代码不起作用。

代码语言:javascript
复制
@property (nonatomic, retain) UIAlertView *activityAlertView;
- (void)viewDidLoad 
{
self.activityAlertView = [[UIAlertView alloc] initWithTitle:@"Receiving data" message:@"\n\n"
                                                         delegate:self
                                                cancelButtonTitle:@"Cancel"
                                                otherButtonTitles:nil, nil];  
[activityAlertView show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
}

-(void) myfunc
{
[self alertView:activityAlertView clickedButtonAtIndex:1];
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-02-07 02:35:33

UIAlertView类的- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated方法可以完成您想要的操作。例如:

代码语言:javascript
复制
[myAlertView dismissWithClickedButtonIndex:-1 animated:YES];
票数 57
EN

Stack Overflow用户

发布于 2012-01-27 18:31:23

由于您使用的是UIAlertView的委托回调方法,因此我认为最好使用以下代码

代码语言:javascript
复制
[myAlertView dismissWithClickedButtonIndex:0 animated:YES]; 

如果不是,则使用上面建议的代码

代码语言:javascript
复制
[myAlertView dismissWithClickedButtonIndex:-1 animated:YES];
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4915256

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档