从customcell转到viewController

发布于 2024-12-10 20:58:02 字数 505 浏览 0 评论 0原文

我有一个加载自定义单元格的表格视图。自定义单元格有一个按钮,单击该按钮将打开一个选择器视图,其中有可供选择的选项。

问题是 modalViewController 方法不起作用,它给出以下错误。

Selector *sel = [[Selector alloc]initWithNibName:@"Selector" bundle:nil];
[self PresentModalViewController:sel animated:YES];
error:property presentModalViewController not found on object of type CustomCell *...and selector is the pickerview controller class...the method is written in ibaction function in customcell.m file   

v 如何从自定义单元格调用其他视图?

谢谢

i am having a tableview in which custom cells are loaded.Custom cell has a button on click of which a pickerview will open which will have options to choose from.

The problem is that modalViewController method is not working, it is giving the following error.

Selector *sel = [[Selector alloc]initWithNibName:@"Selector" bundle:nil];
[self PresentModalViewController:sel animated:YES];
error:property presentModalViewController not found on object of type CustomCell *...and selector is the pickerview controller class...the method is written in ibaction function in customcell.m file   

How can v call other view from custom cell?

thanks

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

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

发布评论

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

评论(1

兔姬 2024-12-17 20:58:02

首先,将你的类命名为“Selector”是一个非常令人困惑的想法。您应该使用更具描述性的内容,并且还不是 obj-c 关键字。

至于你的问题,我认为你应该使用委托来获取从单元视图到控制器的引用。在您的自定义单元视图类中,执行以下操作:

@property (nonatomic, assign) id delegate;

// implementation
@synthesize delegate = _delegate;

// in your cell... method
[self.delegate presentPicker];

在这里,委托 ivar 将指向您的视图控制器。要进行设置,请找到分配单元的位置,然后执行

ACell *aCell = [ACell alloc] init];
aCell.delegate = self;

First, naming your class "Selector" is a horribly confusing idea. You should use something more descriptive, and something that is not already an obj-c keyword.

As for your problem, I think you should use a delegate to get a reference from your cell view to the controller. In your custom cell view class, do something like:

@property (nonatomic, assign) id delegate;

// implementation
@synthesize delegate = _delegate;

// in your cell... method
[self.delegate presentPicker];

Here, the delegate ivar would point back to your view controller. To set that up, find the place where you alloc your cell, and do

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