didSelectRowAtIndexPath 中的详细信息项显示为 null

发布于 2024-11-10 02:13:52 字数 1133 浏览 6 评论 0原文

现在我有一个表格,其中列出了许多 PDF。用户可以从表中选择 PDF,它将显示在视图中。现在,当我从表中选择项目时,它应该将 detailView 的详细项目更改为我选择的行中的项目,此外还将变量 i 更改为所选的行号。

这是我的 DidSelectRowAtIndexPath 方法的样子:

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

    affirmaPDFViewController.detailItem = [NSString stringWithFormat:@"%@", [listOfPDF objectAtIndex:indexPath.row]];
    affirmaPDFViewController.i = indexPath.row;

    NSLog(@"%d", indexPath.row); //returns the proper value
    NSLog(@"%@", [listOfPDF objectAtIndex:indexPath.row]); //returns the proper value

    //NSLog(@"%d", affirmaPDFViewController.i); //DOES NOT return the proper value
    //NSLog(@"%@", affirmaPDFViewController.detailItem); //DOES NOT return the proper value

}

对于前两个 NSLog,它们显示正确的信息,但是当我检查最后两个时,它们会显示 affirmaPDFViewController.i = 0 且 affirmaPDFViewController.detailItem = null。当我需要 affirmaPDFViewController.i= indexPath.row 和 affirmaPDFViewController.detailItem = 我选择的行中的项目时。

有人知道为什么他们没有提出正确的价值观吗?

提前致谢!

Right now I have a table with a number of PDFs listed. From the table the user can select a PDF and it will be displayed in the view. Right now when I select and item from the table it should change the detailView's detailItem to the item in the row I selected, in addition change the variable i to the selected row number.

Here is what my DidSelectRowAtIndexPath method looks like:

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

    affirmaPDFViewController.detailItem = [NSString stringWithFormat:@"%@", [listOfPDF objectAtIndex:indexPath.row]];
    affirmaPDFViewController.i = indexPath.row;

    NSLog(@"%d", indexPath.row); //returns the proper value
    NSLog(@"%@", [listOfPDF objectAtIndex:indexPath.row]); //returns the proper value

    //NSLog(@"%d", affirmaPDFViewController.i); //DOES NOT return the proper value
    //NSLog(@"%@", affirmaPDFViewController.detailItem); //DOES NOT return the proper value

}

for the first two NSLog's, they display the proper information, however when i check the last two they come out with affirmaPDFViewController.i = 0 and affirmaPDFViewController.detailItem = null. When i need the affirmaPDFViewController.i= indexPath.row, and affirmaPDFViewController.detailItem = the item in the row I selected.

Anyone know why they aren't coming out with the proper values?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葮薆情 2024-11-17 02:13:52

您的 affirmaPDFViewController 实例为零。检查创建它的方法,并记住您可以在调试器中设置断点来查看它是否是有效的对象。

Your instance of affirmaPDFViewController is nil. Check the method where it's created, and remember you can set a breakpoint in the debugger to see if it's a valid object or not.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文