Tôi có chế độ xem bảng bên trong Trình điều khiển chế độ xem. Tôi có thể điền tất cả thông tin của mình vào trong chế độ xem bảng. Tuy nhiên tôi là một chút bị mất cho việc thiết lập các quan điểm chi tiết. Tôi tin rằng mỗi tế bào bảng cần một segue để xem từng chi tiết nhưng không hoàn toàn chắc chắn.Đẩy vào Chế độ xem chi tiết từ ô xem bảng bằng cách sử dụng Bảng phân cảnh Xcode
Đây là mã của tôi. Tôi đang thiếu gì để hoàn thành phân đoạn từ chế độ xem bảng đến các chế độ xem chi tiết? Mã số:
.h
@interface DetailViewController : UIViewController <UITableViewDelegate,UITableViewDataSource>
{
IBOutlet UITableView *myTable;
NSMutableArray *contentArray;
}
@property (strong, nonatomic) IBOutlet UITableView *myTable;
.m
- (void)viewDidLoad
{
contentArray = [[NSMutableArray alloc]init];
[contentArray addObject:@"Espresso"];
[contentArray addObject:@"Latte"];
[contentArray addObject:@"Capicino"];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
//Table Information
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [contentArray count];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if([[contentArray objectAtIndex:indexPath.row]isEqualToString:@"EspressoViewController"])
{
EspressoViewController *espresso = [[EspressoViewController alloc]initWithNibName:@"EspressoViewController" bundle:nil];
[self.navigationController pushViewController:espresso animated:YES];
}
else if ([[contentArray objectAtIndex:indexPath.row] isEqualToString:@"Latte"])
{
LatteViewController *latte = [[LatteViewController alloc] initWithNibName:@"Latte" bundle:nil];
[self.navigationController pushViewController:latte animated:YES];
}
}
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
[self tableView:tableView didSelectRowAtIndexPath:indexPath];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"CellIdentifier"];
}
NSString *cellValue = [contentArray objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.textLabel.font = [UIFont systemFontOfSize:16];
cell.detailTextLabel.text = @"Hot and ready";
UIImage *image = [UIImage imageNamed:@"coffeeButton.png"];
cell.imageView.image = image;
cell.textLabel.text = [contentArray objectAtIndex:indexPath.row];
return cell;
}