0
在我的應用程序中,我試圖從一個TableViewCell導航到一個新的視圖,但我不知道如何。你能幫幫忙嗎?我正在使用Xcode 4.6。和.xib,沒有故事板。我對編碼非常陌生,所以請儘可能簡單地解釋它!這裏是我所嘗試過的,請糾正我:如何從TableViewCell推送新視圖?
- (void)viewDidLoad
{
tableData = [[NSArray alloc] initWithObjects:@"aaoversikt1", @"Paul", @"George", @"Ringo", nil];
[super viewDidLoad];
UILabel *nav_title1 = [[UILabel alloc] initWithFrame:CGRectMake(60, 10, 220, 25)];
nav_title1.font = [UIFont fontWithName:@"Arial-BoldMT" size:18];
nav_title1.textColor = [UIColor whiteColor];
nav_title1.adjustsFontSizeToFitWidth = NO;
nav_title1.textAlignment = NSTextAlignmentCenter;
nav_title1.text = @"Ålesund";
nav_title1.backgroundColor = [UIColor clearColor];
self.navigationItem.titleView = nav_title1;
}
#pragma mark - TableView Data Source methods
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section;
{
return [tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *cell = nil;
static NSString *CellIdentifier = @"Cell";
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
return cell;
}
#pragma mark - TableView Delegate methods
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
AAOversiktViewController *aaoversikt1 = [[AAOversiktViewController alloc] initWithNibName:@"AAOversiktViewController" bundle:nil];
[self.navigationController pushViewController:aaoversikt1 animated:YES];
}
謝謝!
看起來你已經實現了didSelecdtRowAtIndexPath:正確。你看到什麼問題?請注意,創建aaoversikt1後,你通常會與有關所選小區的信息進行配置。 – GoZoner 2013-03-04 18:21:48