0

私のアプリでは、TableViewCellから新しいビューに移動しようとしていますが、方法がわかりません。みんなを助けてくれませんか?Xcode4.6を使用しています。および.xib、ストーリーボードなし。私はコーディングにとても慣れていないので、できるだけ簡単に説明してください!これが私が試したことです、私を訂正してください:

- (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];
}

ありがとう!

4

1 に答える 1

0

一見すると、問題は [self.navigationController pushViewController] メソッド内にあると言えます。アプリのデリゲートまたはルート ビュー コントローラーのいずれかで、アプリのナビゲーション コントローラーを開始しましたか?

そうでない場合、私はお勧めします:

 [self presentViewController:aaoversik1 animated:YES completion:NULL];

戻るボタンが表示されるようにナビゲーション スタックをプッシュしたい場合は、UINaviationController の実装を検討します。

それ以外の場合は、カスタムの戻るボタンを作成し、この投稿と同じ方法を使用してルート ビュー コントローラーを表示できます (UINavigationController を使用する方がはるかにクリーンであるため、完全にはお勧めしません)。

これが役に立ったかどうか教えてください、T

于 2013-03-05T01:20:18.727 に答える