2012-03-10 90 views
1

我有一個屬性,特別是在UITableViewCell(可重用)的子類UIActivityIndicatorView。當選中一個單元格時,將從URL中獲取AVAsset,但我希望UIActivityIndicatorView在從URL中獲取足夠的數據並且準備好使用AVAsset時隱藏。但我不知道如何訪問被選中的單元格。我想最好的辦法是設置一個指向屬性中最後一個選定單元格的指針,然後像這樣訪問它。訪問屬性的自定義UITableView單元格

@interface 
@property (nonatomic, retain) customTableViewCustomCell *activeCell; 
@end 

@implementation 
@synthesize activeCell; 

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // remember pointer to active cell for later 
    activeCell = [tableView cellForRowAtIndexPath:indexPath]; 
} 

- (void) updateInterface 
{ 
    [activeCell.activityIndicator stopAnimating]; 
} 

但我得到一個編譯錯誤約不兼容的指針類型,因爲cellForRowAtIndexPath:indexPath返回一個UITableViewCell,而不是一個customUITableViewCell。我需要一個指向customUITableViewCell的指針,所以我有權訪問activtyIndicatorIBOutlet屬性。

+0

您可以嘗試使用NSNotification中心,而直到足夠的數據被下載和使用委託方法,你可以刷新你的表。 – 2012-03-10 12:19:02

回答

1

試試這個

activeCell = (customTableViewCustomCell *) [tableView cellForRowAtIndexPath:indexPath]; 
+0

啊......舊的類型轉換。應該知道。 – TijuanaKez 2012-03-11 04:17:57