2015-03-02 64 views
0

我有一个表格视图。因为我必须在单元格中添加动画图像。我尝试了一些条件,但仍然不起作用。在下面的编码中我犯了什么错误。如何在uitableviewcell中添加动画图像

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

if([ststus isEqual:@"43"]) 
{ 
NSArray *animationArray=[NSArray arrayWithObjects: 
          [UIImage imageNamed:@"unselect.png"], 
          [UIImage imageNamed:@"select.png"], 

          nil]; 

    UIImageView *animationView; 
    animationView.animationImages=animationArray; 
     animationView=[[UIImageView alloc]initWithFrame:CGRectMake(130, 50,36, 36)]; 
    animationView.animationDuration=90; 
    animationView.animationRepeatCount=0; 
    [animationView startAnimating]; 


cell.animation.image= animationView; 
} } 

最后一行有一个警告:Incompatible pointer types assigning to 'UIImage *' from 'UIImageView *'在我的表视图单元格动画图像不appearing.please任何一个可以帮助我在coding.how我能做到这一点的过程。

回答

-1

您可以将cell.animation.image中的UIImage *类型的'image'属性更改为UIImageView *,它将删除将UIImageView实例分配给UIImage实例的上述警告。

1

首先,不要创建新的ImageView - UITableViewCell应该已经有一个可用,您可以直接设置它的.animationImages属性。其次,您需要为.image属性指定相同大小的图像,否则标准UITableViewCell layoutSubviews()会将标签保留在其默认位置,并且不会为动画图像留出空间。