我已經用數組的數據創建了一個tableview。現在我想要詳細瞭解tableview的所有行。如果我從桌面視圖中選擇任何食譜,它應該向我展示所有的配料和程序,以準備該食譜與頂部的特定配方的圖片。我對這個領域很陌生,所以很有幫助。Tableview with details
這裏的 「ViewController.m」
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
RecipeList = [[NSMutableArray alloc]init];
[RecipeList addObject:@"Chicken Kabab"];
[RecipeList addObject:@"Chicken Tikka"];
[RecipeList addObject:@"Chicken 65"];
[RecipeList addObject:@"Chicken Do Pyaza"];
CGRect frame = self.view.frame;
RecipeTable = [[UITableView alloc]initWithFrame:frame style:UITableViewStylePlain];
RecipeTable.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
RecipeTable.backgroundColor = [UIColor cyanColor];
RecipeTable.delegate = self;
RecipeTable.dataSource = self;
[self.view addSubview:RecipeTable];
[RecipeTable setScrollEnabled:YES];
[RecipeTable setUserInteractionEnabled:YES];
[RecipeTable setRowHeight:35];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return @"RECIPES";
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return RecipeList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
}
cell.textLabel.text = [RecipeList objectAtIndex:indexPath.row];
return cell;
}
@end
如果我理解你的問題什麼你想在這裏得到你在桌面視圖中點擊的配方的詳細信息? – Meera 2013-02-26 06:21:02
http://www.iphonesdkarticles.com/2009/01/uitableview-loading-detail-view.html – 2013-02-26 06:21:57
@MeeraJPai是的。我只想要那張特別的菜的照片。 – Newbee 2013-02-26 06:42:28