微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么选择单元格后视图笔尖无法打开?

如何解决为什么选择单元格后视图笔尖无法打开?

| 我创建了nib文件,并且正确完成了所有连接。当我运行该应用程序并选择一个单元格时,新的笔尖根本无法打开。请帮忙!
    - (void)tableView:(UITableView *)tableView 
 didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    //Get the selected country
Nsstring *selectedCountry = [[Nsstring alloc] initWithFormat:@\"you pressed for this.\"];

//Initialize the detail view controller and display it.
DetailViewController *dvController = [[DetailViewController alloc] 
                                      initWithNibName:@\"DetailView\" bundle:[NSBundle mainBundle]];

dvController.selectedCountry = selectedCountry;
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
dvController = nil;

}
    

解决方法

        您似乎没有正确设置
delegate
(基于没有记录
NSLog
语句的输出),否则将正确记录
null
或某些对象值。您需要重新检查您的IB连接,或者如果您已通过编程方式进行了此操作,则执行
tableView.delegate = self;
    ,        尝试这个:
DetailViewController *dvController = [[DetailViewController alloc] 
                                      initWithNibName:@\"DetailView\" bundle:[NSBundle mainBundle]];

dvController.selectedCountry = selectedCountry;
[self.navigationController pushViewController:dvController animated:YES];
dvController = nil;
    ,        希望您尝试从listviewcontroller加载detailvewcontroller。表格视图是listviewcontroller的成员。 该问题的可能原因。 如果您要将listviewcontroller.view作为子视图添加到任何其他viewcontollers视图,则 [self.navigationController pushViewController:dvController动画:是];不工作。 因此,您应该获取应用程序委托的实例,然后执行以下操作。
YourAppDelegate *appDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];

[appDelegate .navigationController pushViewController:dvController animated:YES];
检查一下。如果这不是您遇到问题的原因,请告知控制台输出Deepak询问您。     ,        不要同时释放
dvController
并将其设置为
nil
-只做一个。     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。