如何让 UILable 响应 IBAction?

发布于 12-14 11:17 字数 512 浏览 1 评论 0原文

我已经自定义了 UITableViewCell (从笔尖加载的静态内容)。该单元格包含一个 UILable,我想在用户点击它时更改其值。 (将显示 PickerView,用户可以从中选择该标签的值)。

所以我创建了以下 IBAction。但是当我尝试将它与 UIlable 连接时,它不允许我这样做。

-(IBAction)selectlanguage:(UILabel *)sender
{
/*
 Code to display pickerview and select appropriate language
 */

self.languageLable.text=@"Spanish";

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.userTranslationLanuage = @"en|sp";
}

谁能告诉我我错过了什么?

苏米特

I have customized UITableViewCell (Static Content Loaded from nib). This cell contains one UILable and I would like to change its value when user taps on it. (PickerView will be displayed and from that user can pick value for that lable).

So I have created following IBAction. But when I tried to connect it with that UIlable it does not allowed me to do so.

-(IBAction)selectlanguage:(UILabel *)sender
{
/*
 Code to display pickerview and select appropriate language
 */

self.languageLable.text=@"Spanish";

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
appDelegate.userTranslationLanuage = @"en|sp";
}

Can anyone tell me what I am missing?

Sumit

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

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

发布评论

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

评论(1

西瑶2024-12-21 11:17:54

只需在连接到此 IBAction 的标签上放置一个不可见的按钮即可。 UILabel 对象并不打算直接响应用户触摸。

Just put an invisible button on the label that's connected to this IBAction. UILabel objects are not intended to respond directly to user touches.

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