【问题标题】:Unrecognized selector - using indexpath.row to send a string to view2无法识别的选择器 - 使用 indexpath.row 将字符串发送到 view2
【发布时间】:2013-12-24 23:38:21
【问题描述】:

我无法将字符串传递给第二个视图。我正在尝试获取所选 tableviewcell 的 indexpath.row 并传递关联的字符串,但不断收到“无法识别的选择器..” 使用 DLog 时,控制台会显示正确的字符串。在视图上即时传递信息。我有一个 NSString 设置。感谢您的任何帮助,您可以提供!

这是prepareforsegue代码:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"kShowMovie"])
    {
        MoviePlayerNEWViewController *dvc = (MoviePlayerNEWViewController *)[segue destinationViewController];

        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        DemoVideos *demovideo = [_tableContents objectAtIndex:indexPath.row];

        dvc.videoDemoString = demovideo.vd_link;


        DLog(@"Video link to pass = %@",demovideo.vd_link);
    }

    UIViewController * controller = segue.destinationViewController;
    [controller setHidesBottomBarWhenPushed:YES];
}

【问题讨论】:

  • 请显示完整的错误信息。
  • Martin,这是错误消息的其余部分:2013-12-24 18[22715:1803] TestFlight:已安装崩溃处理程序 2013-[22715:70b] persistentStoreCoordinator 2013-app[22715: 17411] TestFlight:已开始会话 2013-app[22715:17411] TestFlight:应用令牌被识别 2013-12-24 18:28:20.701 app[22715:70b] NSUbiquitousKeyValueStore 错误:com.app.app 没有有效的 com.apple .developer.ubiquity-kvstore-identifier 权利 2013-12-24 18:28:22.413 app[22715:70b] -[UINavigationController setVideoDemoString:]:无法识别的选择器发送到实例 0xcee5f40 (lldb)

标签: objective-c xcode ios7


【解决方案1】:

错误消息表明您尝试调用 setVideoDemoString: on 的控制器是 UINavigationController,而不是您认为的 MoviePlayerNEWViewController。你可能想要这个:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"kShowMovie"])
    {
        UINavigationController *nav = segue.destinationViewController;
        MoviePlayerNEWViewController *dvc = nav.topViewController;

        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        DemoVideos *demovideo = [_tableContents objectAtIndex:indexPath.row];

        dvc.videoDemoString = demovideo.vd_link;


        DLog(@"Video link to pass = %@",demovideo.vd_link);
    }

    UIViewController * controller = segue.destinationViewController;
    [controller setHidesBottomBarWhenPushed:YES];
}

【讨论】:

  • 谢谢!就是这样。感谢您的帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-28
  • 1970-01-01
相关资源
最近更新 更多