提示框UIAlertView/UIAlertViewController的简单使用

IOS 8 前

  

UIAlertView创建提示框


dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

       
       
UIAlertView *alertV = [[UIAlertView alloc]initWithTitle:@"您的幸运号码是:" message:@"1,2,3,4,5,6" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
       
       
//显示
        [alertV
show];
       

    });



IOS 8 


UIAlertViewController


1、设置代理调用


 //执行代理方法
   
if ([self.delegate respondsToSelector:@selector(modalWithAlertController:)]) {
       
//有方法则执行
        [
self.delegate modalWithAlertController:self];

    }


2、控制器实现

-(void)modalWithAlertController:(CZWheelVIew *)alertcontroller
{
   
//创建提示框控制器
   
UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"您的幸运号码是:" message:@"1,2,3,4,5,6" preferredStyle:UIAlertControllerStyleAlert];
   
   
//创建一个动作
   
UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
       
//继续匀速旋转
        [
self.wheelView startRotate];
       
    }];
   
   
//动作添加给提示框控制器
    [alertC
addAction:alertA];
   
   
//控制器弹出控制器
    [
self presentViewController:alertC animated:YES completion:nil];

}


你可能感兴趣的:(提示框)