UITableView 中的弹出窗口
我想在按下某些按钮时显示带有 UITableView
的弹出窗口作为内容(这有效),然后将所选项目作为字符串作为按钮标题或一些文本视图文本。我找到了一些关于如何使用协议执行此操作的示例,但仍然出现错误。 我的代码:
在 popoverViewController.h 中,
@protocol popoverViewControllerDelegate <NSObject>
-(void)getRowText:(NSString *)string;
@end
我声明一个 id delegate2 变量并将其属性设置为:
@property(nonatomic,assign) id<popoverViewControllerDelegate> delegate2;
在 popoverViewController.m 文件中,我合成该变量,在 didSelectRowAtIndexPath
方法中,我有这个,这一行似乎导致我遇到的错误:
[self.delegate2 getRowText:[someArray objectAtIndex:indexPath.row];
在 mainViewController.m 中,我将 popoverViewControllerDelegate 添加到 ViewControllers 协议并导入其头文件。然后在 -(void)getRowText:
方法中有一些代码不会被调用。
UIPopovers
等是根据需要设置的,当我在表格视图中按下一行时就会出现问题。我得到了
由于未捕获而终止应用程序 例外 'NSInvalidArgumentException',原因: '* -[UIPopoverViewController getRowText:]:无法识别的选择器 发送到实例 0x57ca80'
有人可以就此提供一些建议吗?
I would like to display popovers with UITableView
's as content (this works) on some button presses and then get the selected item as string as buttontitle or some textview text. I've found a few example on how to do this with protocols but still get an error.
My code:
In popoverViewController.h
@protocol popoverViewControllerDelegate <NSObject>
-(void)getRowText:(NSString *)string;
@end
I declare an id delegate2 variable and set its property to:
@property(nonatomic,assign) id<popoverViewControllerDelegate> delegate2;
In the popoverViewController.m file I synthesize the variable, and in didSelectRowAtIndexPath
method I have this, and this line seems to cause the error I`m having:
[self.delegate2 getRowText:[someArray objectAtIndex:indexPath.row];
In mainViewController.m I add the popoverViewControllerDelegate to the ViewControllers protocol and have its header file imported. And then have some code in the -(void)getRowText:
method which doesnt get called.
UIPopovers
and such are set up as they work as needed, problem arises when I press a row in the tableview. I get the
Terminating app due to uncaught
exception
'NSInvalidArgumentException', reason:
'* -[UIPopoverViewController
getRowText:]: unrecognized selector
sent to instance 0x57ca80'
Could anyone give some advice with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于发现了错误,简直不敢相信我/它是多么愚蠢。
我有一个 viewController.delegate2 = self.使用句点而不是分号,我想知道为什么它会编译。
Finally found the error and cant believe how silly I/it was.
I had a viewController.delegate2 = self. line with period instead of a semicolon, I wonder why it compiled tho.