好的,首先我不得不说我在 iOS 领域有点菜鸟。也就是说,我将进一步解释我的问题。
我正在制作一个应用程序,用户可以在其中获取动物列表。当用户从列表中选择动物时->第二个视图控制器打开并且必须将那里的图像视图设置为所选动物+有动物的描述。
在我的 viewController2.m 的 ViewDidLoad 中使用这部分代码
- (void)viewDidLoad
{
[super viewDidLoad];
[self.navigationItem setTitle:@"Animal"]; //here the title has to be set to the animal but I will try this later
// Do any additional setup after loading the view from its nib.
UIImage * cowImage = [UIImage imageNamed:@"cow.png"];
UIImage * horseImage = [UIImage imageNamed:@"horse.png"];
ViewController1 *viewController1 = [[ViewController1 alloc]init];
characterNumber = viewController1.pickedRow;
//set the uiimageview based on characternumber
switch (characterNumber) {
case 0:
foto.image = pukkelpopImage;
detailInfo.text = @"blabla";
[self.navigationItem setTitle:characterName];
break;
case 1:
foto.image = cactusImage;
break;
default:
break;
}
}
在我的 ViewController 1.m 中,当一个项目被选中时,我有这个方法。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
ViewController2 *ViewController22 = [[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:nil];
[[self navigationController] pushViewController:ViewController22 animated:YES];
pickedRow = indexPath.row; //As you can see here I try to get which row was tapped
}
问题可能出在哪里?感谢您阅读