rebeling
rebeling

Reputation: 728

How to put an UITextField or UIButton into a NSString

I have a NSString i.e. 'Hello Mr <>. How are you?' and I want to have the <> as an UITextField to enter something or an UIButton to call a select list.

What is the best way to do this?

My idea is to count the letters from 0 to '<'-1, this is the start position of the UITextfield. Place the UITextfield via CGRect there. 0 + start position + length of UITextfield is my end position where I place the rest of the string and so on. But it will be complicate in respect to lineBreakMode and the different size of letters i.e. length of i vs. m etc.

Any ideas how to put the UITextField into the NSString, that I can work with string as normal?

Upvotes: 0

Views: 360

Answers (2)

boreas
boreas

Reputation: 1061

NSPredicate might behave like what you described, I don't think it will do what you want.

Upvotes: 1

knuku
knuku

Reputation: 6102

I'd combine UILabel with UITextField or UIButton, there are some frame size calculations to do, but there is nothing to oppose. Correct me if I'm wrong.

Perhaps, Interface Builder could help you to do it effortlessly.

Upvotes: 1

Related Questions