Tod*_*ddB 5 uitableview uiviewanimation
很简单的情况,多行和一次只有一行应该有复选标记。用户选择行 X,行 X 获得复选标记,从先前选定的行中删除复选标记。但是如何为更改设置动画?(淡入淡出)。
我想也许这会奏效:
[UIView animateWithDuration:1.0 animations:^{
cell.accessoryType = UITableViewCellAccessoryNone;
cell.accessoryType = UITableViewCellAccessoryCheckmark;
previous.accessoryType = UITableViewCellAccessoryCheckmark;
previous.accessoryType = UITableViewCellAccessoryNone;
}];
Run Code Online (Sandbox Code Playgroud)
并且
[tableView reloadRowsAtIndexPaths:paths withRowAnimation:UITableViewRowAnimationFade];
Run Code Online (Sandbox Code Playgroud)
第一个什么也没做,第二个删除了路径数组中 NSIndexPath 引用的两个单元格。我还尝试在 [tableView beginUpdates/endUpdates] 中包装 reloadRowsAtIndexPaths。
更新:
在传入的 indexPath(下面的简单实现)上调用 reloadRowsAtIndexPath 正在做同样的事情,该行“变为空白”。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
Run Code Online (Sandbox Code Playgroud)
该表是一个静态表,我为每个单元格声明并合成了属性,cellForRowAtIndexPath为每一行返回相应的单元格...
.h
@property (strong, nonatomic) IBOutlet UITableViewCell *cellNever;
@property (strong, nonatomic) IBOutlet UITableViewCell *cell030;
@property (strong, nonatomic) IBOutlet UITableViewCell *cell100;
.m
@synthesize cellNever;
@synthesize cell030;
@synthesize cell100;
...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [cells objectAtIndex:indexPath.row];
}
- (void) viewDidLoad {
cells = [NSArray arrayWithObjects:cellNever, cell030, cell100, cell130, cell200, cell230, cell300, cell400, cell500, nil];
}
Run Code Online (Sandbox Code Playgroud)
非常感谢。
| 归档时间: |
|
| 查看次数: |
817 次 |
| 最近记录: |