iPhone应用程序中未加载其他视图

iPhone应用程序中未加载其他视图,iphone,objective-c,ios,Iphone,Objective C,Ios,我在实现文件中使用以下代码。问题是,当我单击一行时,它不会将我带到另一个视图 请帮忙 -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 3; } -(UITableViewCell *)tab

我在实现文件中使用以下代码。问题是,当我单击一行时,它不会将我带到另一个视图

请帮忙

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

return 3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {

    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

}

cell.textLabel.text = [NSString  stringWithFormat:@"Vehicle List %d", [indexPath row]+1];

return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

if (self.vehic == nil) {
    Vehicle *vehicle = [[Vehicle alloc] initWithNibName:@"Vehicle" bundle:[NSBundle mainBundle]];

    self.vehic = vehicle;
}

[self.navigationController pushViewController:self.vehic animated:YES];
}

要转到其他视图,应正确处理此方法:-

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

// on click on any row now it will go to Another View, let the other view be SecondViewController's View

SecondViewController *viewController = [[SecondViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
[self presentModalViewController:viewController animated:YES]; 

}

就这些。如果您遇到任何问题,请告诉我。:)

如果在
didSelectRow…
中放置一个NSLog,那么代码会被执行吗?车辆是UIViewController子类?提供一些关于车辆和车辆对象的信息。。。!谢谢兄弟,你解决了我的问题。现在告诉我,如果每一行代表不同的数据,那么该如何做…请参阅dude CellForRowatinedExath方法自动为表中的每一行调用,您只需做一件事,只要点击任何一行,就在didSelectRow方法中的APPDELEGATE类数组中获取相应的数据,然后转到下一个ViewController。现在在CellForRowPathatinex中设置如下:-[cell.textLable.text:YourArray ObjectAtIndex:indexPath.row]