2011-09-15 44 views
0

我希望我的應用有5行,每行有特定的高度。每一行都有一個標題,副標題和一個圖像。然後,我希望能夠導航到下一頁,當我點擊任一行(例如說第三行)。我該怎麼做呢?如何從一個單元格導航到下一個視圖?

+0

我知道你可以使用自定義單元格添加圖像和標籤,但有沒有其他方式可以在表格視圖中做到這一點? – wOlVeRiNe

+0

我仍然不知道如何通過選擇特定的行來導航到下一頁,我的意思是每行將導航到不同的頁面,而不是鞋子不同的數據,那麼我該怎麼做? – wOlVeRiNe

回答

1

答到新視圖你問題的第二部分是initWithStyle:UITableViewCellStyleSubtitle ...。這個可以讓你有一個標題和副標題。對於圖像,每個單元格都已經內置。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
     if (cell == nil) 
    { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; 
     cell.accessoryType = UITableViewCellAccessoryNone; 
    } 
    NSString *title = (@"your title"); 
    NSString *subTitle = (@"your subtitle"); 
    cell.textLabel.text = title; //title 
    cell.detailTextLabel.text = subTitle; //subtitle 
    NSString *filePath = //file path to your image 
    UIImage *image = [UIImage imageWithContentsOfFile:filePath]; 
    cell.imageView.image = [myThumbnailClass image]; //image 
} 
0

使用的tableview委託方法

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    {  
     singleProductViewController=[[SingleProductViewController alloc]initWithNibName: @"SingleProductViewController" bundle:nil]; 
     [self.navigationController pushViewController:singleProductViewController animated:YES]; 
     [singleProductViewController release];  
    } 

SingleProductViewController是要導航

所有最優秀的

+0

謝謝,這真的很有幫助,但仍然沒有回答我的整個問題:p,如果你也可以幫助我與其他部分,這將不勝感激。 – wOlVeRiNe

+0

由「其他部分」我的意思是,我如何插入圖像和標籤或任何其他細胞沒有使用自定義單元格?那可能嗎? – wOlVeRiNe

+0

默認情況下,tableview單元格具有標題,說明和圖像屬性。如果你想要更多的標籤是你想要定製你的細胞的細胞。 – Warrior

1
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

if(indexPath.row==0) 
{ 
singleProductViewController=[[SingleProductViewController alloc]initWithNibName:@"SingleProductViewController" bundle:nil]; 
    [self.navigationController pushViewController:singleProductViewController animated:YES]; 
[singleProductViewController release]; 
} 
else if(indexPath.row==1) 
{ 
//Sec view Navigation 
} 
//Like wise u go on 


} 
相關問題