分级列表显示
2016-02-24 00:00
302 查看
这是个效果图
设计思想是,使用左右两个tableview分别展示
NSArray * _allArr;NSMutableArray * _rightArr;
UITableView * _leftTableView;
UITableView * _rightTableView;
初始化
_arr = @[@{@"全部":@[ @"棉花", @"小麦", @"水稻", @"甘蔗", @"葡萄", @"玉米", @"花生", @"葡萄", @"玉米", @"花生"]}, @{@"大田作物":@[@"小麦", @"水稻", @"甘蔗"]}, @{@"经济作物":@[@"棉花", @"小麦", @"水稻", @"甘蔗"]}, @{@"蔬菜作物":@[@"小麦", @"水稻", @"甘蔗", @"葡萄", @"玉米"]}, @{@"水果作物":@[@"葡萄", @"玉米", @"花生"]}];_rightArr = [[_arr[0] allValues] firstObject];
创建视图
_leftTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width / 2, 0)];_rightTableView = [[UITableView alloc] initWithFrame:CGRectMake(self.view.frame.size.width / 2, 0, self.view.frame.size.width / 2, 0)];
- (void)buttonAction {
[UIView animateWithDuration:0.3 animations:^{
_leftTableView.frame = CGRectMake(0, 0, self.view.frame.size.width / 2, 44 * 5);
_rightTableView.frame = CGRectMake(self.view.frame.size.width / 2, 0, self.view.frame.size.width / 2, 44 * 8);
}];
}
numberOfRow
if (tableView == _rightTableView) {return _rightArr.count;
}
return _arr.count;
uitableViewCell
if (tableView == _leftTableView) {cell.textLabel.text = [[_arr[indexPath.row] allKeys] firstObject];
} else {
cell.textLabel.text = _rightArr[indexPath.row];
}
didselect
_rightArr = [[_arr[indexPath.row] allValues] firstObject];if (_rightArr.count < 9) {
_rightTableView.frame = CGRectMake(self.view.frame.size.width / 2, 0, self.view.frame.size.width / 2, 44 * _rightArr.count);
} else {
_rightTableView.frame = CGRectMake(self.view.frame.size.width / 2, 0, self.view.frame.size.width / 2, 44 * 8);
}
[_rightTableView reloadData];
相关文章推荐
- 一位技术老鸟写给同事的前端学习路线(附web学习路线图)
- Java ClassLoader
- IM协议设计
- 创业的第一百二十九天
- Springmvc SimpleMappingExceptionResolver
- springmvc 将post转换为delete,put
- PHP 7.1是否支持操作符重载?
- ios app 发布新版本心得 记录
- 如何解决eclipse中的中文乱码问题:
- 关于TCP/IP学习记录(1)
- 使用MD5加密
- Hadoop/Spark生态圈里的新气象【转】
- Linux查看程序端口占用情况
- 自定义UITableViewCell
- oc 中 json 布尔值的判断
- ios 时间操作 根据当前时间 获取昨天 今天 明天
- PHP json_decode返回null解析失败原因
- PHP 使用 header 跳转支付界面,传递不过参数
- PHP实现排序算法
- 活该