alert html ios
iOS Alert
2017-02-21 15:35:00 weixin_34220963 阅读数 3
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert"
                                                                   message:@"This is an alert."
                                                            preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK"
                                                            style:UIAlertActionStyleDefault
                                                          handler:^(UIAlertAction * action) {}];
    
    [alert addAction:defaultAction];
    [self presentViewController:alert animated:YES completion:nil];
}

</br></br>


1916415-60b4c7718c2f0b3b.png

转载于:https://www.jianshu.com/p/97b92326a2e9

2016-12-21 16:08:36 jameskaron 阅读数 18

1。Alert View

 UIAlertView * al = [[UIAlertView alloc]initWithTitle:userInfo message:nil delegate:self cancelButtonTitle:@"✅" otherButtonTitles:nil];
 [al show];

 

 

2.alert controller

 

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Warn" message:@"The logout operation failed" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:sureAction];
[self presentViewController:alert animated:YES completion:nil];

 

 3.添加点击事件

UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *sureAction){
                
                NSLog(@"Alert dialog sure action clicked");
                if (_buttonDialog == 0) { //disable enable_wifi_switch yes
                    _buildGuestWifi = [[HwGuestWifiInfo alloc] init];
                    _buildGuestWifi.enabled = false;
                    [self setGuestWifiInfo:_buildGuestWifi];
                    [self getGuestWifiInfo];
                    
                }else if (_buttonDialog ==1){
                    [self save];
                }
            }];

 

4.带输入框:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"BlackList" message:@"Add black list" preferredStyle:UIAlertControllerStyleAlert];

//addTextFieldWithConfigurationHandler(关键)
    [alert addTextFieldWithConfigurationHandler:^(UITextField *textField){
        textField.placeholder = @"blacklist mac";
    }];
    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *sureAction){
//获取文本框对象,读取值
        UITextField *addBlacklistTv = alert.textFields.firstObject;
        
        [self add2Blacklist:addBlacklistTv.text];
        
    }];
    [alert addAction:sureAction];
    [self presentViewController:alert animated:YES completion:nil];

 

参考:http://www.cocoachina.com/ios/20141126/10320.html

2016-11-08 15:37:00 weixin_34040079 阅读数 17

自定义alert的思路

自定义alert其实很简单,只要实现两个主要方法就可以了。这两个方法一个是show,一个是dismiss。
show方法逻辑:显示蒙层,将自定义alertView加载到当前的window(自定义window更好,这样window 的级别可以设置更高一点,就不会受到rootController设置的影响了,具体可见我的文章UIWindow用法)上,
dismiss方法逻辑:移除蒙层,将alertView从当前的window上移除

这里我只简单介绍一下思路,我自己写了一个YSBaseAlert,这个类里集中处理了show和dismiss方法,如果需要自定义alert,只要继承自这个类,在子类实现UI布局即可。
喜欢的朋友可以参考一下,下面是YSBaseAlert的GitHub地址:
GitHub

2018-05-31 16:45:00 weixin_34189116 阅读数 29

Alert文本文字默认是中心对齐的,于是我用笨办法写了个可以左对齐的方法,效果图先贴出来,接着上代码.

1857051-3c6a2a08af23eecf.png
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"加班狗 更新提示!" message:@"1. 修复了熬夜两天还能继续嗨的bug\n2. 精力恢复速度下调\n3. 转眼往事几率大幅提高" preferredStyle:UIAlertControllerStyleAlert];

    UIView *subView1 = alert.view.subviews[0];
    UIView *subView2 = subView1.subviews[0];
    UIView *subView3 = subView2.subviews[0];
    UIView *subView4 = subView3.subviews[0];
    UIView *subView5 = subView4.subviews[0];
    
    //分别拿到title 和 message 可以分别设置他们的对齐属性
//    UILabel *title = subView5.subviews[0];
    UILabel *message = subView5.subviews[1];
    
    message.textAlignment = NSTextAlignmentLeft;
    
    UIAlertAction * cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    [alert addAction:cancelAction];

    [self presentViewController:alert animated:YES completion:nil];
}

2015-12-29 13:36:21 xiaobo0134 阅读数 758

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{

    

    [self finishLoad];

    [self webViewLoading];

}

- (void)finishLoad

{

    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

    [self.hud stopAnimationWithLoadText:@"" withType:YES];//加载成功


禁用、、、、、、

    [self.webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];

    [self.webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];

    

}


创建IOS的alert界面

阅读数 301

iOS alert sheet 样例

阅读数 215

iOS弹出对话框样例

博文 来自: wangmanjie
没有更多推荐了,返回首页