IOS UIAlertView 上添加View

来源:互联网 发布:人工智能属于什么专业 编辑:程序博客网 时间:2024/05/21 21:41
UIView *popView = [[UIView alloc] initWithFrame:CGRectMake(5.0, 0.0, 200.0, mobilesArray.count * 44)];            for (int i = 0; i < mobilesArray.count; i++) {                                NSString *title = [mobilesArray objectAtIndex:i];                                UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];                [button setTitle:title forState:UIControlStateNormal];                [button setTitleColor:MAIN_BTN_NORMAL_COLOR forState:UIControlStateNormal];                [button setTitleColor:MAIN_BTN_HIGHT_COLOR forState:UIControlStateHighlighted];                                [button setBackgroundImage:IMAGENAMED(@"main_btn_hight") forState:UIControlStateHighlighted];                button.frame = CGRectMake(0, i * 44, 200, 40);                [popView addSubview:button];                                [button addTarget:self action:@selector(alertButtonAction:) forControlEvents:UIControlEventTouchUpInside];            }                        if (!self.mainAlertView) {                self.mainAlertView = nil;            }            self.mainAlertView = [[UIAlertView alloc] initWithTitle:@"拨打电话" message:@"" delegate:nil cancelButtonTitle:STR_CANCEL otherButtonTitles:nil, nil];            [self.mainAlertView setValue:popView forKeyPath:@"accessoryView"];            [self.mainAlertView show];

取消alertView的方法

    [self.mainAlertView dismissWithClickedButtonIndex:0 animated:YES];


0 0
原创粉丝点击