我用数组中的数据创建了一个表格视图。现在我想要 tableview 的所有行的详细信息。如果我从表格视图中选择任何食谱,它应该向我显示准备该食谱的所有成分和程序,并在顶部带有该特定食谱的图片。我是这个领域的新手,所以请帮忙。
这是“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