UIAlertController

UIAlertController 框架内容

//UIAlertController头文件
@interface **UIAlertController** : UIViewController

//类方法创建弹框控制器
//title:标题
//message:信息
//preferredStyle:类型
+ (instancetype)alertControllerWithTitle:(nullable NSString *)title message:(nullable NSString *)message preferredStyle:(UIAlertControllerStyle)preferredStyle;

//添加事件
//action:事件
- (void)addAction:(UIAlertAction *)action;
@end

UIAlertController 类初始化方法

+ (instancetype)alertControllerWithTitle:(nullable NSString *)title message:(nullable NSString *)message preferredStyle:(UIAlertControllerStyle)preferredStyle;

UIAlertAction 框架内容

NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertAction : NSObject <NSCopying>

+ (instancetype)actionWithTitle:(nullable NSString *)title style:(UIAlertActionStyle)style handler:(void (^ __nullable)(UIAlertAction *action))handler;

@property (nullable, nonatomic, readonly) NSString *title;
@property (nonatomic, readonly) UIAlertActionStyle style;
@property (nonatomic, getter=isEnabled) BOOL enabled;

@end
#pragma mark -设置单元格编辑模式
-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath{
    return _style;
}
根据点击确定按钮拿出输入数据并且加入到数组中
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath;
#pragma mark -根据点击确定按钮拿出输入数据并且加入到数组中
UIAlertAction* isOK  = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {

    PersonModel* model = [[PersonModel alloc]init];
    //取出数据  根据alert.textFields数组下标
    model.name = alert.textFields[0].text;
    model.phoneNum = alert.textFields[1].text;
    model.address = alert.textFields[2].text;
    model.sex = alert.textFields[3].text;
    //插入数据
    [self.person_array insertObject:model atIndex:indexPath.row];
    //刷新数据
    [self.tableView reloadData];
}];

猜你喜欢

转载自blog.csdn.net/ios_qing/article/details/52448754
今日推荐