簡體   English   中英

如何使用nib文件為表視圖創建動態單元格

[英]How to create a dynamic cell for a table view using nib files

我正在學習如何使用筆尖和一般的新手。

我有一個表視圖和另一個視圖,我在其中創建對象來填充此表視圖。 我也在使用核心數據。

我的表視圖沒有填充...這是我的cellForRowAtIndexPath:

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

    static NSString *cellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];

    Target *target = [self.fetchedResultController objectAtIndexPath:indexPath];

    cell.textLabel.font = [UIFont fontWithName:@"Candara-Bold" size:20];

    cell.textLabel.text = target.body;

    // Configure the cell...

    return cell;
}

這是我的筆尖:

在此輸入圖像描述

很想在這里得到幫助...謝謝!!

你可以使用autolayout我認為這是最簡單的方法!

當你使用筆尖時,你必須注冊你的筆尖

示例: tableView.registerNib (UINib (nibName: StoreCell, bundle: nil), forCellReuseIdentifier: StoreCell)

並且您必須將UILabel行數設置為0

這個測試項目為你https://www.dropbox.com/s/i5cwzok1327vv1e/tableTest.zip?dl=0 在這里輸入鏈接描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM