2013-03-29 19 views
0

我有一個原型細胞與標籤無法更改爲原型電池標籤中的iOS

@property (nonatomic, strong) IBOutlet UILabel *itemName; 

類ECOMAdmPanelViewCell聲明和類設置爲在身份檢查器中的細胞。出口itemName - 標籤已創建。

在此功能

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"admPanelCell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 
    if (cell == nil) 
     cell = [[ECOMAdmPanelViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    cell.itemName.text = [items objectAtIndex:indexPath.row]; 

    // Configure the cell... 

    return cell; 
} 

我得到一個錯誤信息屬性「ITEMNAME」不是類型的對象的UITableViewCell'找到。誰能告訴我什麼是錯的?

回答

1

與此

ECOMAdmPanelViewCell *cell = (ECOMAdmPanelViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 
+0

感謝您的代碼版本) – ShurupuS

1

試試這個

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"admPanelCell"; 
    ECOMAdmPanelViewCell *cell = (ECOMAdmPanelViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 
    if (cell == nil) 
     cell = [[ECOMAdmPanelViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 

    cell.itemName.text = [items objectAtIndex:indexPath.row]; 

    // Configure the cell... 

    return cell; 
} 
+0

是啊更改您此行

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

它工作,thx! – ShurupuS

1

或使用本:

(ECOMAdmPanelViewCell *)cell.itemName 
+0

是的,現在我明白了,謝謝 – ShurupuS