Tap-Geste auf einen Teil des UILabel

Konnte ich erfolgreich hinzufügen Tippen Sie auf gesten zu einem Teil von UITextView mit dem folgenden code:

UITextPosition *pos = textView.endOfDocument;//textView ~ UITextView

for (int i=0;i<words*2-1;i++){//*2 since UITextGranularityWord considers a whitespace to be a word

    UITextPosition *pos2 = [textView.tokenizer positionFromPosition:pos toBoundary:UITextGranularityWord inDirection:UITextLayoutDirectionLeft];
    UITextRange *range = [textView textRangeFromPosition:pos toPosition:pos2];
    CGRect resultFrame = [textView firstRectForRange:(UITextRange *)range ];

    UIView* tapViewOnText = [[UIView alloc] initWithFrame:resultFrame];
    [tapViewOnText addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(targetRoutine)]];
    tapViewOnText.tag = 125;
    [textView addSubview:tapViewOnText];

    pos=pos2;
}

Wünsche ich, Sie zu imitieren, die das gleiche Verhalten in einem UILabel. Das Problem ist, UITextInputTokenizer (verwendet, um die tokenisierung der einzelnen Worte) ist deklariert in UITextInput.h, und nur UITextView & UITextFieldentsprechen UITextInput.h; UILabel nicht.
Gibt es eine Abhilfe für dieses ??

Hallo Freund, haben Sie überprüft die Benutzer-Interaktion, Verhalten von UILabel, weil standardmäßig userinteraction ist NICHT von UIlabel, werden Sie haben, um es JA.Lassen Sie mich wissen, ist es oder nicht funktioniert.!!!
Aktion auf eine ganze UILabel ist nicht ein Problem, es ist 'Teil' der UILabel.
Bitte überprüfen Sie stackoverflow.com/questions/8811909/...

InformationsquelleAutor n00bProgrammer | 2013-07-24

Schreibe einen Kommentar