iphone - Create UIButton on substring with help of NSRange -



iphone - Create UIButton on substring with help of NSRange -

i stuck @ point unable proceed in application. have text coming server. may single line or multiline text. have display text on uilabel, no problem me. problem is, have display uibutton on finding particular substring of same text. illustration text nitish\n435-234-6543\nindia beingness displayed follows :

nitish 435-234-6543 republic of india

so, when find 435-234-6543 have display uibutton on 435-234-6543.

important : 1. text dynamic - coming server. above example. 2. uibutton subview of uilabel.

i tried different ways ohattributedlabel, rectforletteratindex , this too. not getting success. thought is, create button when substring found , set frame of button based on nsrange of substring. possibility? how can done? or there other way this? posting code won't problem me. guess approach worried here about. please allow me know if more clarification required. thanks, nitish

-->i have tried calcluate position didnt success. seems lots of work calcualate position. 1 immediate solution come mind why not taking 1 or 2 labels , 1 button.

suppose. got dynamic string webservice is: "nitesh-56789-test".

find range of string suppose i.e. "56789". string before starting location of range assign 1 label i.e. assign "nitesh" lable one. now add together 1 custom button our searched string text(56789). now create sure in main string there after our substring or not. here mean after our search string "56789" still "test" remain assign 3rd lable.

here have figue out frame of labels , button using dynamic height width calculation using sizewithfont method.

iphone ios nsstring uibutton nsrange

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -