9.26. The use of IOS warning dialog box

发布时间 : 2025-10-25 13:32:32 UTC      

Page Views: 9 views

The warning dialog box is used to provide important information to the user.

You can proceed to further use the application only after you select an option in the warning dialog box view.

9.26.1. Important attribute

  • AlertViewStyle

  • CancelButtonIndex

  • Delegate

  • Message

  • NumberOfButtons

  • Title

An important method

- (NSInteger)addButtonWithTitle:(NSString *)title 
- (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex 
- (void)dismissWithClickedButtonIndex: (NSInteger)buttonIndex animated:(BOOL)animated 
- (id)initWithTitle:(NSString *)title message: (NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString*)otherButtonTitles, ... 
- (void)show 

9.26.2. Update ViewController.h, as shown below

让类符合警告对话框视图的委托协议,如下所示,在ViewController.h中添加

#import  @interface ViewController : UIViewController<UIAlertViewDelegate>{ } @end    

Add a custom method addAlertView

-(void)addAlertView{ UIAlertView *alertView = [[UIAlertView alloc]initWithTitle: @"Title" message:@"This is a test alert" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil]; [alertView show]; } 

Execute the delegate method for the warning dialog view

#pragma mark - Alert view delegate - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex{ switch (buttonIndex) { case 0: NSLog(@"Cancel button clicked"); break; case 1: NSLog(@"OK button clicked"); break; default: break; } } 

Modify the viewDidLoad in ViewController.m, as follows

(void)viewDidLoad { [super viewDidLoad]; [self addAlertView]; } 

9.26.3. Output

Now when we run the application, we will see the following output:

alertOutput1

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。