2012-02-14 7 views
1

私はUITableVIewを持っています。今私は自分自身でUITableViewCellを作った。しかし、私のテーブルが現れなければ何も表示されません。しかし、細胞は依然として選択可能であり、DetailViewを開く。どのコマンドを忘れましたか?UITableViewCellがテーブルに表示されません

//Customize the appearance of table view cells. 
-(UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"MainTableCell"; 

    MainTableCell *cell = (MainTableCell*)[tableView dequeueReusableCellWithIdentifier:Cel lIdentifier]; 

    if (cell == nil) { 
     cell = [[[MainTableCell alloc] initWithStyle:UITableViewCellStyleDef ault reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    // Configure the cell. 
    VerwaltungInformation *selectedFormel = [listOfFormularies objectAtIndex:indexPath.row]; 

    cell.FormelNameLabel.text = selectedFormel.nameFormel; 

    return cell; 
} 

特別なものを追加する必要がありますか?誰かがもっとコードを必要とするなら、教えてください。ここで


は私MainTableCell.hです:

import <UIKit/UIKit.h> 
@interface MainTableCell : UITableViewCell { 
    UILabel *FormelNameLabel; 
    UILabel *ErklaerungVerfuegbarLabel; 
    UILabel *BeispielVerfuegbarLabel; 
    UILabel *RechnerVerfuegbarLabel; 
} 

@property (nonatomic, retain) IBOutlet UILabel *FormelNameLabel; 
@property (nonatomic, retain) IBOutlet UILabel *ErklaerungVerfuegbarLabel; 
@property (nonatomic, retain) IBOutlet UILabel *BeispielVerfuegbarLabel; 
@property (nonatomic, retain) IBOutlet UILabel *RechnerVerfuegbarLabel;` 
@end 

そして、ここでは私のMainTableCell.mです:

#import "MainTableCell.h" 

@implementation MainTableCell 
@synthesize FormelNameLabel;` 
@synthesize ErklaerungVerfuegbarLabel; 
@synthesize BeispielVerfuegbarLabel; 
@synthesize RechnerVerfuegbarLabel;` 

- (void)dealloc { 
    [FormelNameLabel release]; 
    [ErklaerungVerfuegbarLabel release]; 
    [BeispielVerfuegbarLabel release]; 
    [RechnerVerfuegbarLabel release]; 
    [super dealloc]; 
} 
@end 
+0

データソースとtableViewの代理人を正しく接続しましたか?もしそうなら、 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)セクションに戻り、戻り値を調べてください。(行の数でなければなりません) – Stas

+0

テーブルは動作しますが、セルは、テーブルセルに署名を取得しません。私はcellinをrootviecontroller.hまたは他のどこかで宣言しなければなりませんか? MainTableCell.hをインポートしただけなので、何もしなかったので... – Daniel05

答えて

0

あなたは

cell. VerwaltungInformation *selectedFormel = [listOfFormularies objectAtIndex:indexPath.row]; 

も、この行をコメントしていますチェックwthr

selectedFormel.nameFormel 

には任意の値が含まれます。

+0

selectedFormel.nameFormelは文字列を返します。しかし、私はあなたのポストの最初の部分とは何を意味するのかわかりません... – Daniel05

0

私は答えようとします。 1. label.textに設定する前に、この値selectedFormel.nameFormelをNSLogに書き込んでください。

NSLog(@"selectedFormel.nameFormel:%@", selectedFormel.nameFormel); 

2.セルを正しく設定しましたか?たとえば、FormelNameLabelのフレームがゼロでないと確信していますか?

NSLog(@"cellFrame:%@", NSStringFromCGRect(cell.frame)); 

ラベルをセルにサブビューとして追加してもよろしいですか? これらのことがすべて完了しても、セルからコードを提供するものはまだありません。

+0

私の共謀:selectedFormel.nameFormel:PQ-Formel; cellFrame:{{0、0}、{320、44}} - 今は? MainTableCell.h/.mを投稿する必要がありますか? – Daniel05

+0

はい、投稿する必要があります – Stas

関連する問題