ios 关于UITableView UITableViewCellAccessoryCheckmark 混乱的(3)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-01 14:19 点击:次
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellStr= @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellStr];
}
NSArray *keys=[tempResult allKeys];
NSArray *dicts= [tempResult valueForKey:[keys objectAtIndex:indexPath.section]];
NSDictionary *temp=[dicts objectAtIndex:indexPath.row];
cell.textLabel.text=[temp valueForKey:@"name"];
if([selectedData containsObject:temp]){
cell.accessoryType=UITableViewCellAccessoryCheckmark;
}else{
cell.accessoryType=UITableViewCellAccessoryNone;
}
return cell;
}
static NSString *cellStr= @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellStr];
}
NSArray *keys=[tempResult allKeys];
NSArray *dicts= [tempResult valueForKey:[keys objectAtIndex:indexPath.section]];
NSDictionary *temp=[dicts objectAtIndex:indexPath.row];
cell.textLabel.text=[temp valueForKey:@"name"];
if([selectedData containsObject:temp]){
cell.accessoryType=UITableViewCellAccessoryCheckmark;
}else{
cell.accessoryType=UITableViewCellAccessoryNone;
}
return cell;
}
上面的if else 要完整。
其实思想就是MVC,视图只是用来展示,到底展示什么取决于model;
相关新闻>>
- 发表评论
-
- 最新评论 进入详细评论页>>
今日头条
更多>>您可能感兴趣的文章
- iphone开发之object c基础一定义接口
- IOS开发学习一 :Cocoa环境熟悉和Xcode使用
- iPhone开发进阶(4) --- 使用Makefile自动编
- iphone-用代码创建界面(Creating Views from Code)
- IOS学习五:UITabBarController初步
- uiview某点返回色How to get the color of a pixel in an UI
- IOS学习之十二:Core Location定位和MapKit视图使
- ios Archive 步骤
- 提交应用遇到"Missing Screenshot"问题的
- iPhone开发:类似iChat的聊天泡泡示例
新闻点评
新闻关注排行榜
热门推荐
最新推荐