2012-04-07 12 views
0

画像とその横にあるテキストを含むカスタムリストを表示するには次のコードがありますが、与えられた5つのサンプルデータで満たされたリストは表示されません。誰かが私を助けることができるか???カスタムUITableViewが表示されない

#import "RestListViewController.h" 
#import "RestListCustomTableCell.h" 

@implementation RestListViewController 

/* 
// The designated initializer. Override to perform setup that is required before the view is loaded. 
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 
     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
     if (self) { 
     // Custom initialization 
} 
return self; 
} 
*/ 

/* 
// Implement loadView to create a view hierarchy programmatically, without using a nib. 
- (void)loadView { 
} 
*/ 


    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 
    - (void)viewDidLoad { 
[super viewDidLoad]; 
    } 
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:      (NSIndexPath  *)indexPath { 
    //NEVER REACHES HERE!!!!!!!!!! 
NSLog(@"BUILD THE TABLE!!!"); 
static NSString *CellIdentifier = @"Cell"; 
RestListCustomTableCell *cell = (RestListCustomTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[RestListCustomTableCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
} 

// Set up the cell… 

switch (indexPath.row) { 

    case 0: 
     cell.primaryLabel.text = @"Meeting on iPhone Development"; 
     cell.secondaryLabel.text = @"Sat 10:30"; 
     cell.myImageView.image = [UIImage imageNamed:@"restabapiknik.png"]; 
     break; 
    case 1: 
     cell.primaryLabel.text = @"Call With Client"; 
     cell.secondaryLabel.text = @"Planned"; 
     cell.myImageView.image = [UIImage imageNamed:@"restburgerking.png"]; 
     break; 
    case 2: 
     cell.primaryLabel.text = @"Appointment with Joey"; 
     cell.secondaryLabel.text = @"2 Hours"; 
     cell.myImageView.image = [UIImage imageNamed:@"restburgerstory.png"]; 
     break; 
    case 3: 
     cell.primaryLabel.text = @"Call With Client"; 
     cell.secondaryLabel.text = @"Planned";   
     cell.myImageView.image = [UIImage imageNamed:@"restkfc.png"]; 
     break; 
    case 4: 
     cell.primaryLabel.text = @"Appointment with Joey"; 
     cell.secondaryLabel.text = @"2 Hours"; 
     cell.myImageView.image = [UIImage imageNamed:@"restmcdonalds.png"]; 
     break; 
    default: 
     break; 
} 
return cell; 
} 

/* 
    // Override to allow orientations other than the default portrait orientation. 
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationPortrait); 
    } 
    */ 

- (void)didReceiveMemoryWarning { 
// Releases the view if it doesn't have a superview. 
[super didReceiveMemoryWarning]; 

// Release any cached data, images, etc that aren't in use. 
} 

    - (void)viewDidUnload { 
// Release any retained subviews of the main view. 
// e.g. self.myOutlet = nil; 
} 


- (void)dealloc { 
[super dealloc]; 
} 

@end 

とヘッダーファイルは次のとおりです。

#import <UIKit/UIKit.h> 

@interface RestListViewController : UITableViewController { 
NSMutableArray  * myStrings; 
} 
@property(nonatomic, retain)NSMutableArray * myStrings; 

@end 

答えて

2

あなたがテーブルビュー

でのUITableViewクラスを拡張
//.m 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return 10; // numbers of rows 
} 
+1

を表示する行数を表すデリゲートのメソッドを追加する必要があります彼らが割り当てられているので、代理人の割り当てを実行する必要はありません – WhiteTiger

+0

ありがとうWhiteTiger、問題解決:) – dramaticlook

関連する問題