我需要有人来帮助我切换自定义单元格时选择使用didSelectRowAtIndexPath
,所以想法是将自定义cell1
设置为一个状态,当用户选择它会消失,并且cell2
将淡入其中,显示该州的首府,但其他单元格将保持为除选定的单元格之外的单元格。TableView和自定义单元格
0
A
回答
1
这是如何内部的观点我会做...
tableView.h:
#import <UIKit/UIKit.h>
@interface tableView : UITableViewController {
NSMutableArray *tableArray;
}
- (void)changeTitleAtIndexPath:(NSIndexPath *)indexPath;
@end
tableview.m(添加这些方法):
在 - (无效)viewDidLoad中添加:
tableArray = [[NSMutableArray alloc] init];
[tableArray addObject:[NSMutableArray arrayWithObjects:[NSNumber numberWithBool:NO],@"City1",@"Capital1",nil]];
[tableArray addObject:[NSMutableArray arrayWithObjects:[NSNumber numberWithBool:NO],@"City2",@"Capital2",nil]];
[tableArray addObject:[NSMutableArray arrayWithObjects:[NSNumber numberWithBool:NO],@"City3",@"Capital3",nil]];
[tableArray addObject:[NSMutableArray arrayWithObjects:[NSNumber numberWithBool:NO],@"City4",@"Capital4",nil]];
变化:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
if (![[[tableArray objectAtIndex:indexPath.row] objectAtIndex:0] boolValue]) {
cell.textLabel.text = [[tableArray objectAtIndex:indexPath.row] objectAtIndex:1];
}else {
cell.textLabel.text = [[tableArray objectAtIndex:indexPath.row] objectAtIndex:2];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[self changeTitleAtIndexPath:indexPath];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationTop];
}
地址:
- (void)changeTitleAtIndexPath:(NSIndexPath *)indexPath{
BOOL newBool = ![[[tableArray objectAtIndex:indexPath.row] objectAtIndex:0] boolValue];
[[tableArray objectAtIndex:indexPath.row] replaceObjectAtIndex:0 withObject:[NSNumber numberWithBool:newBool]];
}
0
必须使用只有一个格,具有的倍数次(用α-一些视图设置为透明的,或隐藏)
当选择小区,切换动画块
相关问题
- 1. 自定义tableview单元格
- 2. TableView自定义单元格
- 3. TableView自定义单元格UIButton动作
- 4. 多个TableView自定义单元格
- 5. 可可:自定义TableView单元格?
- 6. 自定义TableView单元格未配置
- 7. Tableview自定义单元格按钮
- 8. Tableview跨越另一个tableview和自定义表格单元格不能显示
- 9. 如何在自定义Tableview下创建Tableview单元格
- 10. 如何在自定义tableview单元格内实现tableview?
- 11. Tableview和自定义单元格不可预知的行为
- 12. 与UIButton和UILabel自定义TableView单元格
- 13. 查看表格视图(自定义tableview单元格)
- 14. 在自定义单元格内添加自定义单元格
- 15. UINavigationController在单击自定义TableView单元格后显示黑屏
- 16. JavaFX TableView自定义单元格渲染分割菜单按钮
- 17. 单击自定义单元格的UITextField后重新加载TableView
- 18. 单击一次,多个操作TableView的自定义单元格
- 19. CoreData绑定和自定义单元格
- 20. 在tableview单元中自定义imageview
- 21. 如何动态更改自定义单元格的tableview单元格的高度?
- 22. 如何在tableView中创建自定义单元格(滑动单元格)
- 23. 如何在tableview中创建动态单元格(没有自定义单元格)?
- 24. 自定义单元格和UITableViewController建议
- 25. UITableView和自定义单元格
- 26. UILabels和自定义的UITableView单元格
- 27. UISearchDisplayController和自定义单元格
- 28. TableView自定义单元格不输入初始化方法
- 29. 自定义单元格在TableView中显示不正确
- 30. 自定义单元格不在tableview中加载?
感谢JNK,这正是我一直在寻找,这是伟大的。 – tosi 2010-11-17 15:32:29