//模态—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];
…….未完待续....