OtherViewController *newview =まず、OtherViewControllerインスタンスを作成します。これも、nibファイルを使って生成するので、initWithNibName:というメソッドで初期化をします。
[[[OtherViewController alloc] initWithNibName:
@"OtherViewController" bundle:nil] autorelease];
[[self navigationController] pushViewController:続いて、self(自身、つまりRootViewControllerインスタンス)のnavigationControllerプロパティのpushViewController:animated:というメソッドを呼び出しています。navigationControllerというプロパティは、UINavigationControllerインスタンスが保管されるプロパティです。これはデリゲートクラスであるMyNavAppDelegateクラスの中に用意されています。このUINavigationControllerというのは、ナビゲーションの管理をしている部分のコントローラークラスです。
newview animated:YES];
NSString *msg = [NSString stringWithFormat:ページのプッシュを行ったら、表示するビューにテキストを設定しましょう。先に作成したOtherViewControllerには、UILabelに関連付けたmsgというプロパティを用意しておきました。このプロパティ(UILabel)のsetText:を呼び出して、表示するテキストを変更しておきます。
@"you select No,%i cell.",indexPath.row];
[[newview msg] setText:msg];
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
※RootViewController.mで修正するメソッド - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { OtherViewController *newview = [[[OtherViewController alloc] initWithNibName: @"OtherViewController" bundle:nil] autorelease]; [[self navigationController] pushViewController: newview animated:YES]; NSString *msg = [NSString stringWithFormat: @"you select No,%i cell.",indexPath.row]; [[newview msg] setText:msg]; }
<< 前へ |