1

そんなアプリを作っています。

BooksViewController
↑↓
EditViewController

SQL: books (id INTEGER PRIMARY KEY AUTOINCREMENT, author TEXT, title TEXT, copyright TEXT, category TEXT)

TableViewCell を xib でカスタマイズしました。
cell.label1.text = book.title;
cell.label2.text = book.copyright;
cell.label3.text = book.category;
しかし、データはTableViewCellに反映されません。


私はこのコードを持っています。

BooksViewController

    #import "BooksCell.h"
    //////
            - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        static NSString* CellIdentifier = @"BooksCell";

        BooksCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if( cell == nil )
        {
            cell = [[[BooksCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        }

        Book* book = [self bookAtIndexPath:indexPath];
        cell.label1.text = book.title;
        cell.label2.text = book.copyright;
        cell.label3.text = book.category;

        return cell;
    }

EditViewController

- (IBAction)saveData:(id)sender
{    
    Book* newBook = [[Book alloc] init];
    newBook.bookId    = self.book.bookId;
    newBook.title     = _titleTextField.text;
    newBook.author    = _authorTextField.text;
    newBook.copyright    = _copyrightTextField.text;
    newBook.category    = _categoryTextField.text;

    if( self.book )
    {
        [self.delegate editBookDidFinish:self.book newBook:newBook];
    }
    else
    {
        [self.delegate addBookDidFinish:newBook];
    }
}

BooksCell.h

    #import <UIKit/UIKit.h>

@interface BooksCell : UITableViewCell{
    UILabel* label1;
    UILabel* label2;
    UILabel* label3;
}

@property (nonatomic, retain) IBOutlet UILabel* label1;
@property (nonatomic, retain) IBOutlet UILabel* label2;
@property (nonatomic, retain) IBOutlet UILabel* label3;

@end



セルは空白です。
でも説明すると

cell.textLabel.text = book.title; 

メソッド [cellForRowAtIndexPath] で、タイトルがセルに正しく表示されるようになりました。
どうすれば修正できるかについて何か考えはありますか?

4

0 に答える 0