アプリにグループ化されたテーブルを設定しましたが、新しいビューへのプッシュは正常に機能します。1つを除いて。タイトルとスタックレイアウトはすべて奇妙です。内訳は次のとおりです。
- テーブルには2つのセクションがあります。
- 最初のセクションの最初の行をタップすると、正しいビューに移動しますが、新しいビューのタイトルは、テーブルの2番目のセクションの最初の行の名前です。
- 同様に、最初のセクションのタイトルの2番目の行は、2番目のセクションのタイトルの2番目の行です。
ルートビューテーブルの2番目のセクションの2番目の行をタップすると、ナビゲーションボタンはテーブルの最初のセクションの2番目の行に移動します。
これが私のテーブルの図です:
表セクション1
行1
行2
行3
表セクション2
行A
行B
行C
したがって、行3をタップすると、プッシュされたビューのタイトルは行Cになります。ナビゲーションボタンは、行3に戻るように指示し、最終的にはルートビューになります。
ビューをプッシュする私の実装ファイルは次のとおりです。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//CSS
if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"CSS"])
{
CSSViewController *css = [[CSSViewController alloc] initWithNibName:@"CSSViewController" bundle:nil];
[css setTitle:@"CSS"];
[self.navigationController pushViewController:css animated:YES];
}
//HTML
if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"HTML"])
{
HTMLViewController *html = [[HTMLViewController alloc] initWithNibName:@"HTMLViewController" bundle:nil];
[html setTitle:@"HTML"];
[self.navigationController pushViewController:html animated:YES];
}
//JS
if ([[arryClientSide objectAtIndex:indexPath.row] isEqual:@"JavaScript"])
{
JSViewController *js = [[JSViewController alloc] initWithNibName:@"JSViewController" bundle:nil];
[js setTitle:@"JavaScript"];
[self.navigationController pushViewController:js animated:YES];
}
//PHP
if ([[arryServerSide objectAtIndex:indexPath.row] isEqual:@"PHP"])
{
PHPViewController *php = [[PHPViewController alloc] initWithNibName:@"PHPViewController" bundle:nil];
[php setTitle:@"PHP"];
[self.navigationController pushViewController:php animated:YES];
}
//SQL
if ([[arryServerSide objectAtIndex:indexPath.row] isEqual:@"SQL"])
{
SQLViewController *sql = [[SQLViewController alloc] initWithNibName:@"SQLViewController" bundle:nil];
[sql setTitle:@"SQL"];
[self.navigationController pushViewController:sql animated:YES];
}
&テーブルのデータを供給する配列:
- (void)viewDidLoad {
[super viewDidLoad];
arryClientSide = [[NSArray alloc] initWithObjects:@"CSS",@"HTML",@"JavaScript",nil];
arryServerSide = [[NSArray alloc] initWithObjects:@"Objective-C", @"PHP",@"SQL",nil];
// arryResources = [[NSArray alloc] initWithObjects:@"HTML Colour Codes", @"Useful Resources", @"About",nil];
self.title = @"Select a Language";
[super viewDidLoad];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
どんな助けでも大歓迎です。
ジャック