@@ -22,11 +22,11 @@ - (void)viewDidLoad {
22
22
[super viewDidLoad ];
23
23
// Do any additional setup after loading the view from its nib.
24
24
[_tableView registerNib: [UINib nibWithNibName: @" ProfileTableViewCell" bundle: nil ] forCellReuseIdentifier: @" profilecell" ];
25
- marr = [NSMutableArray arrayWithObject: @" row-0" ];
25
+ marr = [NSMutableArray arrayWithObject: [ NSMutableString stringWithFormat: @" row-0" ] ];
26
26
}
27
27
28
28
- (void )addItem : (id )sender {
29
- [marr insertObject: [NSString stringWithFormat: @" row-%zd " ,marr.count] atIndex: 0 ];
29
+ [marr insertObject: [NSMutableString stringWithFormat: @" row-%zd " ,marr.count] atIndex: 0 ];
30
30
[_tableView insertRowsAtIndexPaths: @[[NSIndexPath indexPathForRow: 0 inSection: 0 ]] withRowAnimation: UITableViewRowAnimationBottom];
31
31
}
32
32
@@ -41,12 +41,14 @@ - (IBAction)removeItem:(id)sender {
41
41
42
42
- (IBAction )updateItem : (id )sender {
43
43
NSIndexPath *indexPath = [_tableView indexPathForCell: [sender superview ].superview];
44
+
45
+ NSMutableString *removedObj = [marr objectAtIndex: indexPath.row];
46
+ [removedObj appendString: @" 更新" ];
47
+ [_tableView reloadRowsAtIndexPaths: @[[NSIndexPath indexPathForRow: indexPath.row inSection: 0 ]] withRowAnimation: UITableViewRowAnimationAutomatic];
44
48
[_tableView beginUpdates ];
45
- id removedObj = [marr objectAtIndex: indexPath.row];
46
49
[marr removeObjectAtIndex: indexPath.row];
47
- [_tableView deleteRowsAtIndexPaths: @[indexPath] withRowAnimation: UITableViewRowAnimationTop];
48
50
[marr insertObject: removedObj atIndex: 0 ];
49
- [_tableView insertRowsAtIndexPaths: @[[ NSIndexPath indexPathForRow: 0 inSection: 0 ]] withRowAnimation: UITableViewRowAnimationBottom ];
51
+ [_tableView moveRowAtIndexPath: [ NSIndexPath indexPathForRow: indexPath.row inSection: 0 ] toIndexPath: [ NSIndexPath indexPathForRow: 0 inSection: 0 ] ];
50
52
[_tableView endUpdates ];
51
53
}
52
54
0 commit comments