Objective c didSelectRowAtIndexPath问题
我有一个在测试中遇到的问题,但现在在一个更大的应用程序中,我似乎无法解决 首先,我有一个有六个按钮的视图,每个按钮加载我正在使用的不同视图:Objective c didSelectRowAtIndexPath问题,objective-c,iphone,uitableview,Objective C,Iphone,Uitableview,我有一个在测试中遇到的问题,但现在在一个更大的应用程序中,我似乎无法解决 首先,我有一个有六个按钮的视图,每个按钮加载我正在使用的不同视图: - (IBAction)showInfo2:(id)sender { InfoViewController *Infocontroller = [[[InfoViewController alloc] initWithNibName:@"InfoView" bundle:nil] autorelease]; Infocontroller.modalTran
- (IBAction)showInfo2:(id)sender {
InfoViewController *Infocontroller = [[[InfoViewController alloc] initWithNibName:@"InfoView" bundle:nil] autorelease];
Infocontroller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:Infocontroller animated:YES];
}
这似乎工作正常,并加载下一节,在本例中为“infoview”。
然后,我加载一个tableview,并从xml提要中填充完整的f数据,这现在又开始工作了(尽管对我来说不是一件容易的任务!)
当我知道如何尝试使用时,问题就出现了:
似乎什么也没有发生,即新视图未加载
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here -- for example, create and push another view controller.
SubInfoViewController *subInfoViewController = [[SubInfoViewController alloc] initWithNibName:@"SubInfoView" bundle:nil];
[self.navigationController pushViewController:subInfoViewController animated:YES];
[subInfoViewController release];
}
我知道它被称为是因为它有效:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *message = [[NSString alloc] initWithFormat:@"You selected a row"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Row Selected" message:message delegate:nil cancelButtonTitle:@"Yes I did" otherButtonTitles:nil];
[alert show];
[message release];
[alert release];
}
欢迎任何帮助,请温柔的新手:)到底是什么问题?您的代码乍一看很好。您的视图可能被推入导航堆栈,但您无法看到它,因为您的父视图是模态视图 您不能尝试这样显示子InfoViewController:
SubInfoViewController *subcontroller=[[SubInfoViewController alloc] initWithNibName:@"SubInfoViewController" withBundle:nil];
[self presentModalViewController:subcontroller animated:YES];
[subcontroller release];
如果您希望在应用程序中保留导航逻辑,则不应以模式显示InfoViewController,而应在导航堆栈中以常见方式显示它
在按下子ViewController之前,可以尝试关闭模式视图。在这种情况下,您必须执行以下操作:
SubInfoViewController *controller=[[SubInfoViewController alloc] initWithNibName:@"SubInfoViewController" bundle:nil];
[self.parentViewController pushViewController:controller animated:YES];
[self dismissModalViewControllerAnimated:YES];
[controller release];
您将收到一条警告,因为parentViewController
可能不会响应pushViewController:animated:
,但使用NSLog
您将看到您的parentViewController
实际上是一个UINavigationController
希望这有帮助 抱歉,它是pushview控制器,似乎没有加载新视图。