views:

211

answers:

2

I want to move a UIAlertView's frame because I am adding a UITextFied to it and when the keypad is hiding the Cancel and Ok buttons that are apart of my alertView

A: 

same problem

nothing help?

vivian
+1  A: 

Do you just want to move the entire alertview around or move the views inside the button around? If the former, UIAlertViews are a UIView subclass. Just use the .frame property.

If its the latter, I would recommend against doing so. Instead, I'd probably suggest a modal view of some sorts. And to file a radar with Apple about making this possible.

Basically, you'd have to subclass UIAlertView to change the view itself. However, it needs pointing out that UIAlertViews are very fragile (the buttons in the view are a private class and, IIRC, the internals have been changed around before).

But if you must, as it stands right now, you're going to need to use a hack. UIAlertView is a UIView subclass and that you can iterate through the subviews as needed. There are only going to be three kinds of views in your view—and two kinds of views (message and title labels, textfields you add in) are public classes that you can check against with - isKindOfClass:.

Alternately, there's also "Make the alert have a message that takes up two lines and add the alertview in so that it covers that subview" at the expense of having a mssage in the alert. Just as hacky, in a different way.

zadr