2011-04-07 88 views
0
-viewDidLoad { 
    tbl.rowHeight = 150; 
    ary = [[NSArray alloc]initWithObjects:@"asdf",@"asd",nil]; 
    ary2 = [[NSArray alloc]initWithObjects:@"google",@"yahoo",nil]; 
} 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 

// Customize the number of rows in the table view. 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return [ary count]; 
} 

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 
    // Configure the cell. 
    cell.textLabel.text = [ary objectAtIndex:indexPath.row]; 
    cell.detailTextLabel.text = [ary2 objectAtIndex:indexPath.row] ; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
     return cell; 
} 

對我來說問題是detailtextlabel在表格視圖中不顯示。我的代碼中是否有錯誤?標籤不顯示在UITableView中

回答

2

你必須設置電池styleSubtitle副標題 像下面

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
0

UITableViewCellStyleDefault之外的任何東西都應該使用detailLabel。

0

在cell的contentView上添加detailtextLabel。

1

更改uitableviestyltDEfault到uitableviewStyleSubtitle