iPhone开发应用之显示无按钮警告框

移动开发 iOS
iPhone开发应用之显示无按钮警告框是本文要介绍的内容,主要讲述的是警告框案例的实现,我们一起来看详细内容讲解。

iPhone开发应用之显示无按钮警告框是本文要介绍的内容,主要讲述的是警告框案例的实现,我们一起来看详细内容讲解。如果要显示一个不需要用户交互的异步信息,可以创建一个不带按钮的UIAlertView。

一般无按钮的警告框有一个特点,它不会自动消失。因此,我们在做完事情之后要收到的让警告框消失。可以调用此方法

  1. – dismissWithClickedButtonIndex:animated: 

下面的代码是创建一个无按钮的UIAlertView,让其在3s之后消失。

  1. UIAlertView *baseAlert;  
  2.  
  3. - (void) action: (UIBarButtonItem *) item  
  4. {  
  5.     baseAlert = [[[UIAlertView alloc] initWithTitle:@"Please Wait" message:nil delegate:self 
  6. cancelButtonTitle:nil otherButtonTitles: nil] autorelease];  
  7.     [baseAlert show];  
  8.  
  9. // Create and add the activity indicator  
  10. UIActivityIndicatorView *aiv = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];  
  11. aiv.center = CGPointMake(baseAlert.bounds.size.width / 2.0f, baseAlert.bounds.size.height - 40.0f);  
  12. [aiv startAnimating];  
  13. [baseAlert addSubview:aiv];  
  14. [aiv release];  
  15.  
  16.  
  17. // Auto dismiss after 3 seconds  
  18. [self performSelector:@selector(performDismiss) withObject:nil afterDelay:3.0f];  
  19. }  
  20.  
  21. - (void) performDismiss  
  22. {  
  23.     [baseAlert dismissWithClickedButtonIndex:0 animated:NO];  

效果如下图:

iPhone开发应用之显示无按钮警告框

小结:iPhone开发应用之显示无按钮警告框的内容介绍完了,希望通过本文的学习能对你有所帮助!

责任编辑:zhaolei 来源: 互联网
相关推荐

2011-08-11 10:27:37

iPhoneUIView视图

2011-08-11 10:16:23

iPhoneUIView视图

2011-08-16 19:02:23

iPhone开发绘图

2011-08-10 10:23:20

iPhoneArchivingNSCoder

2011-08-15 18:02:32

iPhone开发表视图

2011-08-12 11:31:46

iPhoneUIView动画

2011-08-11 11:51:07

iPhone键盘

2011-08-19 14:27:29

iPhone开发

2011-08-11 17:32:51

iPhone视图

2011-07-22 15:32:53

iPhone 按钮 对话框

2011-08-12 10:16:10

iPhone通讯录联系人

2011-08-10 15:36:26

iPhone静态库控件

2011-06-01 14:20:37

Android

2011-08-08 10:10:14

iPhone开发 图片 方法

2011-08-09 17:29:29

iPhone文件屏幕

2011-08-08 16:56:44

iPhone 字符处理 视图

2011-08-10 10:10:21

iPhoneUIPopoverCo

2011-07-19 09:58:36

2011-07-19 09:46:38

2011-07-08 14:58:16

iPhone Xcode iOS
点赞
收藏

51CTO技术栈公众号