2011-05-01 86 views
0

我有一個包含單元格圖像的tableview。Tableview選擇行

如果我觸摸表格中任意一行的圖像,它應該重定向到下一頁,並在下一頁顯示該圖像。

請幫我看看如何做到這一點?

+0

謝謝頭暈 – 2011-05-01 12:10:23

回答

0

使用didSelectRowAtIndexPath方法代表:

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

通過了解使用[indexPath row]你會得到你需要的東西,讓我們假設你存儲其UITableviewCell得到選擇您的UIImages陣列中的MyImagesArray

UIImage* MySelectedImage = [MyImagesArray objectAtIndex:[indexPath row]]; 


這是一個對這個答案的另一個答案評論#3

聲明中UIViewController一個變量,是要顯示的圖像,並通過所選擇的圖像,或者你甚至可以發送UIImage的名字:

ImageViewer* oImageViewer = [[ImageVieweralloc] initWithNibName:@"ImageViewer" bundle:nil]; 

// Assume MyImagesArray contains the images names. 
oImageViewer.sSelectedImageName = [MyImagesArray objectAtIndex:[indexPath row]]; 

[self.navigationController pushViewController:oImageViewer animated:YES]; 

在圖像瀏覽被它的名字,例如加載圖像:

UIImage *image = [UIImage imageNamed:self.sSelectedImageName]; 
+0

@Ahamad你可以詳細說明??我有5行5個圖像,如果我選擇第一行它將重新回到下一頁,並顯示該圖像。 – 2011-05-01 12:13:02

+0

@Nipin pn:很酷,你使用的是'UINavigationController',你想推新的控制器?或者你想添加新的'UIView'? – 2011-05-01 12:14:45

+0

我正在使用UINavigationController,我想將它推到nextview並顯示相應的圖像,我知道如何從一個視圖推送到另一個,但不知道如何傳遞圖像 – 2011-05-01 12:17:58