模态 - block
2015-08-13 09:05
316 查看
//模态—block
#pragma mark - 添加联系人页面跳转
- (void)cancelBarButtonItemAction:(UIBarButtonItem *)sender
{
// 推出的模态视图添加导航控制器
AddContactViewController *addcontacVC = [[[AddContactViewController alloc] init ] autorelease];
// 实现block的赋值
addcontacVC.senderBlock = ^(Contact *c){
// 当block被调用时候, 内部才会执行
NSString *key = [c.name substringToIndex:1];
// 将数据添加到数组的第一个元素的位置
[_allDataMutableDict[key] insertObject:c atIndex:0];
// 获取key的下标 也就是分区的下标
NSInteger index = [_allKeysMutableArray indexOfObject:key];
// 创建表示位置的NSIndexPath对象
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:index];
// 更新页面
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
};
UINavigationController *addcontacNC = [[[UINavigationController alloc]initWithRootViewController:addcontacVC]autorelease];
[self.navigationController presentViewController:addcontacNC animated:YES completion:nil];
}
//按钮
self.loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
_loginButton.frame = CGRectMake(50, 300, 100, 30);
[_loginButton setTitle:@"登录" forState:UIControlStateNormal];
_loginButton.backgroundColor = [UIColor cyanColor];
[self addSubview:_loginButton];
// 创建子视图控制器
ActivityListViewController *activityTVC = [[[ActivityListViewController alloc] initWithStyle:UITableViewStylePlain] autorelease];
// 设置tabBarItem
activityTVC.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"活动" image:[UIImage imageNamed:@"iconfont-hanbao"] selectedImage:nil] autorelease];
// 使用导航控制器进行包裹
UINavigationController *activityNC = [[[UINavigationController alloc] initWithRootViewController:activityTVC] autorelease];
// 添加到标签控制器汇总
self.viewControllers = @[activityNC];
…….未完待续....
#pragma mark - 添加联系人页面跳转
- (void)cancelBarButtonItemAction:(UIBarButtonItem *)sender
{
// 推出的模态视图添加导航控制器
AddContactViewController *addcontacVC = [[[AddContactViewController alloc] init ] autorelease];
// 实现block的赋值
addcontacVC.senderBlock = ^(Contact *c){
// 当block被调用时候, 内部才会执行
NSString *key = [c.name substringToIndex:1];
// 将数据添加到数组的第一个元素的位置
[_allDataMutableDict[key] insertObject:c atIndex:0];
// 获取key的下标 也就是分区的下标
NSInteger index = [_allKeysMutableArray indexOfObject:key];
// 创建表示位置的NSIndexPath对象
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:index];
// 更新页面
[self.tableView insertRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
};
UINavigationController *addcontacNC = [[[UINavigationController alloc]initWithRootViewController:addcontacVC]autorelease];
[self.navigationController presentViewController:addcontacNC animated:YES completion:nil];
}
//按钮
self.loginButton = [UIButton buttonWithType:UIButtonTypeSystem];
_loginButton.frame = CGRectMake(50, 300, 100, 30);
[_loginButton setTitle:@"登录" forState:UIControlStateNormal];
_loginButton.backgroundColor = [UIColor cyanColor];
[self addSubview:_loginButton];
// 创建子视图控制器
ActivityListViewController *activityTVC = [[[ActivityListViewController alloc] initWithStyle:UITableViewStylePlain] autorelease];
// 设置tabBarItem
activityTVC.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"活动" image:[UIImage imageNamed:@"iconfont-hanbao"] selectedImage:nil] autorelease];
// 使用导航控制器进行包裹
UINavigationController *activityNC = [[[UINavigationController alloc] initWithRootViewController:activityTVC] autorelease];
// 添加到标签控制器汇总
self.viewControllers = @[activityNC];
…….未完待续....
相关文章推荐
- Win10的这些功能是否动摇了一个果粉的心
- 盗版win7/win8.1能升级win10吗?如何升级win10正式版?
- 学会在职场中成长
- iBatis2:SqlMap的配置
- Keepalived配置与使用(1)
- UI 06 UIScrollView基础
- D - 排列
- 图像形态学 - 图像金字塔(cvPyrDown、cvPyrUp)
- 【转】oracle的正则表达式
- [转]Java中this的意义
- leetcode_Decode Ways
- 保证完成任务
- ruby on rail 微信企业号回调模式 url初次验证时 签名的加密验证
- 我的高效编程秘诀
- H5调用本地摄像头
- CSS 背景 backround设置
- Mysql-5.5.32 cmake安装
- 我的高效编程秘诀
- hadoop常见操作命令
- 百度地图(Android)多地图重叠bug记录