【发布时间】:2015-04-17 05:04:26
【问题描述】:
我在静态UITableViewCell 中有一个UIView。 view 设置为隐藏在 viewDidLoad 中。当button 被选中时,view 就会可见。
- (void)viewDidLoad {
[self.myView setHidden:YES];
}
- (IBAction)myButton:(id)sender
{
if (self.myView.hidden == YES) {
[self.myView setHidden:NO];
} else {
[self.myView setHidden:YES];
}
[self.tableView beginUpdates];
[self.tableView endUpdates];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 1)
{
if (self.myView.hidden == YES) {
retuen 252 - self.myView.bounds.size.height;
} else return 252;
}
tableView.estimatedRowHeight = 150;
return UITableViewAutomaticDimention;
}
现在发生的情况是,当button 被选中时,view 变得可见并且cells 的高度会随着动画而改变;但是view 会立即可见,并且会妨碍其他对象(直到cells 动画结束)。
我怎样才能让view 也输入动画? (我更喜欢它的高度动画。)
编辑
我尝试了以下动画高度,以便它应该与cell同步
if (self.myView.hidden == YES) {
[self.myView setFrame:CGRectMake(self.myView.frame.origin.x, self.myView.frame.origin.y - self.myView.frame.size.height, self.myView.frame.size.width, self.myView.frame.size.height)];
[self.myView setHidden:NO];
[UIView animateWithDuration:1.0 animations:^(){
[self.myView setFrame:CGRectMake(self.myView.frame.origin.x, 0, self.myView.frame.size.width, self.myView.frame.size.height)];
}];
}
但它所做的只是动画views 位置,(从上到下,)而不是它的高度??
【问题讨论】:
标签: ios objective-c uitableview animation hidden