您的位置:首页 > 移动开发 > IOS开发

iOS开发脚踏实地学习day17-彩票

2015-09-28 16:42 549 查看
1.iOS8不能显示登录画面,设置lauch image
http://www.woowen.com/swift/2014/12/12/ios8%E8%AE%BE%E7%BD%AELaunch%20Image%20%E5%90%AF%E5%8A%A8%E5%9B%BE%E7%89%87/
2.自定义UITableView

//UITableView形式时grouped
- (id)init
{
return [super initWithStyle:UITableViewStyleGrouped];
}


- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
return [self.dataList[section] header];//顶部的字母会自动大写的
}
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section{
return  [self.dataList[section] footer];//底部的字母不会自动大写
}


3.设置cell

-(void)setItem:(CellItems *)item{
_item = item;
//根据item数据来设置cell
//1.设置cell子控件数据
self.imageView.image = [UIImage imageNamed:item.icon];
self.textLabel.text = item.title;
//2.设置cell的右侧视图
//    -(BOOL) isKindOfClass: classObj判断是否是这个类或者这个类的子类的实例
//    -(BOOL) isMemberOfClass: classObj 判断是否是这个类的实例
if ([_item isKindOfClass: [ArrowCellItems class]] ) {
self.accessoryView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"CellArrow"]];
self.selectionStyle = UITableViewCellSelectionStyleDefault;//选中的样式,灰色
//        self.userInteractionEnabled = YES;//能点击
}else if([_item isKindOfClass: [SwitchCellItems class]]){
self.accessoryView = [[UISwitch alloc]init];
self.selectionStyle = UITableViewCellSelectionStyleNone;//选中的样式,无
//        self.userInteractionEnabled = NO;//不能点击,选中样式就不用配置,如果这样的话UISwitch也不能点击了。

}
else{
self.accessoryView = nil;
self.selectionStyle = UITableViewCellSelectionStyleDefault;//选中的样式,灰色
//        self.userInteractionEnabled = YES;//能点击

}

}


4.点击cell跳转

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//取出模型
CellGroup *group = self.dataList[indexPath.section];
NSArray *items = group.items;
CellItems *item = items[indexPath.row];
if ([item isKindOfClass:[ArrowCellItems class]]) {
TestViewController *testVC = [[TestViewController alloc]init];
[self.navigationController pushViewController:testVC animated:YES];
}

}


5.彩票里的设置部分的思路

VIew:继承自TableViewCell

1)item属性,通过setter方法,把数据作为输入,配置cell的item;

2)cellWithTableView,配置cell,tableView作为输入

Model:

1) SettingItem

2) SettingGroup

3) ArrowSettingItem,继承自SettingItem,通过isKindOfClass来设置cell的右侧视图

4) SwitchSettingItem,继承自SettingItem,通过isKindOfClass来设置cell的右侧视图

Controller:

1)dataList,用懒加载的方法

2) section,row,cell,didselectedAtIndex

2) 配置TableView
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: