zoukankan      html  css  js  c++  java
  • Displaying Alerts with UIAlertView

    UIAlertView *alertView = [[UIAlertView alloc]
                                initWithTitle:@"Alert"
                                message:@"You've been delivered an alert"
                                delegate:nil
                                cancelButtonTitle:@"Cancel"
                                otherButtonTitles:@"Ok", nil];
    [alertView show];

     self.view.backgroundColor = [UIColor whiteColor];

    NSString *message = @"Are you sure you want to open this link in Safari?";
    UIAlertView *alertView = [[UIAlertView alloc]
                                initWithTitle:@"Open Link"
                                message:message
                                delegate:self
                                cancelButtonTitle:[self noButtonTitle]
                                otherButtonTitles:[self yesButtonTitle], nil];
    [alertView show];

     more samples

    // one button alert
    UIAlertView *alert =
        [[UIAlertView alloc] 
        initWithTitle: @"Hello"
        message: @"Hello Master HaKu!"
        delegate: self
        cancelButtonTitle: @"OK"
        OtherButtonTitles: nil];
    [alert show];
    [alert release];
    
                                
    // two buttons alert
    UIAlertView *alert =
        [[UIAlertView alloc] 
        initWithTitle: @"Hello"
        message: @"Hello Master HaKu!"
        delegate: self
        cancelButtonTitle: @"YES"
        OtherButtonTitles: @"NO", nil];
    [alert show];
    [alert release];
    
                                
    // more buttons alert
    UIAlertView *alert =
        [[UIAlertView alloc] 
        initWithTitle: @"Hello"
        message: @"Hello Master HaKu!"
        delegate: self
        cancelButtonTitle: @"OK"
        OtherButtonTitles: @"Option1", @"Option2", nil];
    [alert show];
    [alert release];                            
    
    
    
    @interface AlertTestViewController : UIViewController<UIAlertViewDelegate>
    
    @end
    
    // alert click implmentation
    - (void) alertView: (UIAlertView *)alertView
    clickedButtonAtIndex: (NSInteger)buttonIndex
    {
        NSLog(@"%d", buttonIndex);
    }
  • 相关阅读:
    mysql笔记--基础知识
    安全杂乱笔记整理1---常用服务端口总结
    ent orm笔记4---Code Generation
    ent orm笔记3---schema使用(下)
    ent orm笔记2---schema使用(上)
    ent orm笔记1---快速尝鲜
    Linux 更新yum源
    Lua 获取毫秒精度时间
    Linux docker镜像制作
    Linux 中文字符集安装
  • 原文地址:https://www.cnblogs.com/davidgu/p/3461369.html
Copyright © 2011-2022 走看看