iOS开发学习之#提醒处理#(1)响应提醒视图

在这里我用到了视图库里的Navigation Controller导航控制器。

提醒操作主要用到了UIAlertviewDelegate协议中的alertView:clickButtonAtIndex:方法实现,其语法形式如下:

- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;

(UIAlertView *)alertView用来指定警告视图中包含的按钮,(NSInteger)buttonIndex用来指定点击的按钮的索引

核心代码如下:

TableViewController.h

#import <UIKit/UIKit.h>

@interface TableViewController : UITableViewController<UITableViewDataSource,UITabBarDelegate,UIAlertViewDelegate>{
    NSMutableArray *a;
}

- (IBAction)aa:(id)sender;

- (IBAction)bb:(id)sender;
@end

TableViewController.m部分代码片段

- (IBAction)aa:(id)sender {
    UIAlertView *a = [[UIAlertView alloc]initWithTitle:@"编辑" message:@"请选择项目" delegate:self cancelButtonTitle:@"Canel" otherButtonTitles:@"Add",@"Delete", nil];
    [a show];
}

- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSString *b = [alertView buttonTitleAtIndex:buttonIndex];
    if ([b isEqualToString:@"Delete"]) {
        [self setEditing:YES];
    }
    if ([b isEqualToString:@"Add"]) {
       UIAlertView *a1 = [[UIAlertView alloc]initWithTitle:@"添加" message:@"确定要添加联系人吗" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
        [a1 show];
    }
}

- (IBAction)bb:(id)sender {
    [self setEditing:NO];
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [a removeObjectAtIndex:indexPath.row];
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    }
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值