ios - UITextView Detect Word Tap Like Link -
lets have textview holding attributed text such '11 22 333'. want user able tap on 11 , have action occur, tap on 22 , have action occur , on. cant place buttons on top because label changing. how can detect this?
<uitextviewdelegate> textviewforcountdown.delegate = self; //// [hour settext:[nsstring stringwithformat:@"%ld", (long)[components day] * 24 + (long)[components hour]]]; [minute settext:[nsstring stringwithformat:@"%ld", (long)[components minute]]]; [second settext:[nsstring stringwithformat:@"%ld", (long)[components second]]]; [second2 settext:[nsstring stringwithformat:@"%ld", (long)[components second] - 1]]; uifont *mediumfont = [uifont fontwithname:@"futurapt-heavy" size:65]; uicolor *mediumcolor = [self colorwithhexstring:@"ffbc00"]; nsdictionary *arialdict = [nsdictionary dictionarywithobjects:@[mediumfont, mediumcolor] forkeys:@[nsfontattributename,nsforegroundcolorattributename]]; nsmutableattributedstring *aattrstring = [[nsmutableattributedstring alloc] initwithstring:[nsstring stringwithformat:@"%@", second.text] attributes: arialdict]; uicolor *thincolor = [self colorwithhexstring:@"353535"]; nsdictionary *verdanadict = [nsdictionary dictionarywithobjects:@[mediumfont, thincolor] forkeys:@[nsfontattributename,nsforegroundcolorattributename]]; nsmutableattributedstring *vattrstring = [[nsmutableattributedstring alloc]initwithstring:[nsstring stringwithformat:@"%@", minute.text] attributes:verdanadict]; uicolor *thincolor2 = [self colorwithhexstring:@"929292"]; nsdictionary *verdanadict2 = [nsdictionary dictionarywithobjects:@[mediumfont, thincolor2] forkeys:@[nsfontattributename,nsforegroundcolorattributename]]; nsmutableattributedstring *vattrstring2 = [[nsmutableattributedstring alloc]initwithstring:[nsstring stringwithformat:@"%@", hour.text] attributes:verdanadict2]; [aattrstring appendattributedstring:vattrstring]; [aattrstring appendattributedstring:vattrstring2]; textviewforcountdown.attributedtext = aattrstring; //currently textviewforcountdown displays 29 9 381. //the user should able click on 29 , have action occur (action 1) //the user should able click on 9 , have action occur (action 2) //the user should able click on 381 , have action occur (action 3)
Comments
Post a Comment