如何让 UILable 响应 IBAction?
我已经自定义了 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 技术交流群。

只需在连接到此 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.