didSelectRowAtIndexPath 中的详细信息项显示为 null
现在我有一个表格,其中列出了许多 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的
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.