简体   繁体   中英

In the iOS SDK, how can I include a button in a UITextField like Mobile Safari does?

How can I display a button and/or activity indicator inside of a UITextField on the iPhone? I'm trying to reproduce Mobile Safari's location text field which contains either a reload button or a cancel (stop loading) button which is right-justified inside of the text field.

Similarly, when you click inside of the text field (not on the cancel/reload buttons) to edit the URL, a clear icon (x inside of a circle) is shown inside of the text field which will erase the contents of the text field.

How can I create this in my own apps? I cannot seem to do it via Interface Builder so I suspect it's being done in code.

There is a built in option that worked for me...check here:

Adding the "Clear" Button to an iPhone UITextField

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM