2015-03-02 19 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()會將標籤保留在其默認位置,並且不會爲動畫圖像留出空間。