单元格内的视图框架在cellForRowAtIndexPath中没有变化 [英] Frame of View inside the cell not changing in cellForRowAtIndexPath

查看:84
本文介绍了单元格内的视图框架在cellForRowAtIndexPath中没有变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在tableViewCell中有一个View。在某些情况下,我想将视图移动到某个原点 x ,但以下代码无法在 cellForRowAtIndexPath 中运行。如果我在 cellForRowAtIndexPath 完成后使用代码,它的工作正常。

I have a View inside the tableViewCell. In certain conditions I want to move the view to some origin x but the following code not working in cellForRowAtIndexPath. If i use the code after the cellForRowAtIndexPath gets completed, its working fine.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UINib *nib = [UINib nibWithNibName:@"GoalDetailsCustomCardCell" bundle:nil];

[goalDetailsTableView registerNib:nib forCellReuseIdentifier:@"CardCell"];
GoalDetailsTableViewCell *cell = [goalDetailsTableView dequeueReusableCellWithIdentifier:@"CardCell"];

if(cell == nil)
{
    cell = [goalDetailsTableView dequeueReusableCellWithIdentifier:@"CardCell"];
}
if([self.swipedRowArray containsObject:indexPath])
        {
            [UIView animateWithDuration: 0.5 animations:^{
                cell.cardDetails.frame = CGRectOffset(cell.cardDetails.frame, -322.0, 0.0);
                //        CGRectOffset(cell.cardView.frame, -320.0, 0.0);
                cell.actionCardReminder.frame = CGRectOffset(cell.actionCardReminder.frame, -322.0, 0.0);
            }];
}
}

任何人都可以帮助我..提前致谢。

Can anyone Help me.. Thanks in advance.

推荐答案

tableView中使用此动画块:willDisplayCell:forRowAtIndexPath:方法:

-(void)tableView:(UITableView *)tableView willDisplayCell:(GoalDetailsTableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {

if([self.swipedRowArray containsObject:indexPath])
        {
            [UIView animateWithDuration: 0.5 animations:^{
                cell.cardDetails.frame = CGRectOffset(cell.cardDetails.frame, -322.0, 0.0);
                //        CGRectOffset(cell.cardView.frame, -320.0, 0.0);
                cell.actionCardReminder.frame = CGRectOffset(cell.actionCardReminder.frame, -322.0, 0.0);
            }];
  }
}

我不确定它是否适用于您或不是,但我只在此方法中添加了单元格动画。

I am not sure whether it will work for you or not, but I have added cell animations in this method only.

希望这对您也有帮助。

这篇关于单元格内的视图框架在cellForRowAtIndexPath中没有变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆