【问题标题】:UIButton in between the UILabel text+iPhoneUIButton 在 UILabel text+iPhone 之间
【发布时间】:2013-01-07 07:10:58
【问题描述】:

我想在我的应用程序中实现标记功能。

标签中有一些文本,我想在其上给出UIButton 操作事件。

我曾使用此代码来检测特定文本是否存在于 UILabel 中。 如何检查特定文本是否存在以及是否提供UIButton 操作事件?

arr_count = {ABC,DEF,PQR};

FOR(int i = 0; i < [arr_Count]; i++) {
Nsstring *Str_dec1;
   NSRange range = [Str_dec1 rangeOfString:[arr_count objectatindex:i] options:NSCaseInsensitiveSearch];
   if (range.location != NSNotFound) {
       *******.....MISING CODE HERE......*****
   }
}

当我点击UILabel 中的 ABC 或 PQR 或 DEF 文本时,我应该如何编码以便它给我UIButton 操作事件?

【问题讨论】:

  • [arr_Count; i++] 块中的代码 [arr_Count; i++] 对我来说看起来很奇怪(我承认,我不知道可可,所以我可能是错的)。方括号在其中如何工作?

标签: iphone ios uibutton uilabel


【解决方案1】:

您可以在标签上使用UITapGestureRecognizer 来调用UIButton 方法。或者你可以这样做:

 if(condition)
 {
     [self callButtonEvent:sender] // sender can be nil if you aren't passing anything
 } 

condition 用于检查标签的文本是否等于所需的任何字符串。

【讨论】:

  • 。我只想在标签中特定文本区域上的用户选项卡上调用该方法。检测 XYZ 到达标签中的特定区域
【解决方案2】:

你可以直接调用

[self yourButtonActionMethod:nil];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-04
    • 1970-01-01
    • 1970-01-01
    • 2011-07-03
    • 2012-01-09
    相关资源
    最近更新 更多