iOSプログラミングを学んでいて、テーブルビューに問題がありました。テーブルビューのセルをタップして、プログラムを別のビューに変更したいのですが、これが私のコードです。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
testViewController* controller=[[testViewController alloc] initWithNibName:@"testViewController" bundle:nil];
controller.imageView.image=[UIImage imageNamed:@"gyf.jpg"];
[self.navigationController pushViewController:controller animated:YES];
}
testViewControllerによって制御されるビューは非常にシンプルです。その中には画像ビューしかありません。しかし、セルをタップした後、画面には画像のない空白のビューしかありませんでした。デバッグで、後controller.imageView.image=[UIImage imageNamed:@"gyf.jpg"];
、controller.imageviewがnilであることがわかりました。
問題の場所とこの現象が発生する理由を教えてください。Xcode4.3.3を使用し、iPhone5.1シミュレータでプログラムを実行していただきありがとうございます。