2012-03-10 10 views
1

initWithStyleを持つテーブルに対して次のコードを実行しようとしています:UITableViewCellStyleSubtitle、字幕が表示されていません。何が間違っているのか教えていただけますか?initWithStyle:UITableViewCellStyleSubtitleただし字幕が表示されない

ありがとうございます!

#import "ViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 
@synthesize listData; 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    NSArray *array = [[NSArray alloc] initWithObjects:@"Sleepy", @"Sneezy", @"Bashful", @"Happy", @"Doc", @"Grumpy", @"Dopey", @"Thorin", @"Dorin", @"Nori", @"Ori", @"Balin", @"Dwalin", @"Fili", @"Kili", @"Oin", @"Gloin", @"Bifur", @"Bofur", @"Bombur", nil]; 
    self.listData = array; 
} 

- (void)viewDidUnload 
{ 
    [super viewDidUnload]; 
    // Release any retained subviews of the main view. 
    self.listData = nil; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

#pragma mark - 
#pragma mark Table View Data Source Methods 
- (NSInteger)tableView:(UITableView *)tableView 
    numberOfRowsInSection:(NSInteger)section 
{ 
    return [self.listData count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleTableIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] 
       initWithStyle:UITableViewCellStyleSubtitle 
       reuseIdentifier:SimpleTableIdentifier]; 
    } 

    UIImage *image = [UIImage imageNamed:@"star.png"]; 
    cell.imageView.image = image; 

    NSUInteger row = [indexPath row]; 
    cell.textLabel.text = [listData objectAtIndex:row]; 
    return cell; 

    if (row < 7) 
     cell.detailTextLabel.text = @"Mr. Disney"; 
    else 
     cell.detailTextLabel.text = @"Mr.Tolkien"; 
} 

@end 

答えて

0
return cell; 

最後の行にしなければなりません。 detailTextLabeltextプロパティを設定する前に戻ります。

また、「到達できないコード」についてXcodeから警告を受け取ったはずです。

+0

それをしました。ありがとうございました! – pdenlinger

関連する問題