【发布时间】:2014-04-07 00:31:52
【问题描述】:
我有一个表格视图,当我按下按钮时,我会动画到一个新位置。它覆盖了屏幕底部的一小部分,然后按下按钮调用一个方法,使其覆盖大约一半的屏幕。这样用户可以从表格视图中选择一个文件。
但是,似乎当我调用 reloadData 时,表格视图会移回其原始位置,我想阻止这种情况发生,这样用户就不需要每次都按下按钮(例如删除文件、重命名文件或将新文件添加到表视图中)。
有什么想法可以做到这一点吗?
我已经包含了代码。文件 IBAction 是按下按钮时发生的情况。
-(IBAction)file:(id)sender {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
if (self.tableView.frame.origin.y == 457) {
[self tableAppear];
}
else {
[self tableDisappear];
}
}
-(void)tableDisappear {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
if ([[UIScreen mainScreen] bounds].size.height == 568) { [self.tableView setCenter:CGPointMake(160, 545)];
}
else { [self.tableView setCenter:CGPointMake(160, 545)];
}
[UIView commitAnimations];
}
-(void)tableAppear {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
if ([[UIScreen mainScreen] bounds].size.height == 568) { [self.tableView setCenter:CGPointMake(160, 390)];
}
else { [self.tableView setCenter:CGPointMake(160, 390)];
}
[UIView commitAnimations];
}
【问题讨论】:
标签: ios uitableview tableview reloaddata