Reputation: 27618
I have an app that was built on Xcode 4.6 and iOS 6. I am now upgrading it to iOS 7 using XCode 5.
I have this code that worked perfectly on iOS 6. What it does it bring a popup with UITextField in it. User can enter whatever text they want and hit OK. I take their text and put it in a UILabel.
The problem I have is that in iOS 7 when I bring up this pop-up text box, its not editable. Touching it doesn't do anything. How come?
Here is the code and screenshot
// ************
// ENTER TEXT
// ************
-(IBAction)insertText
{
UIAlertView* dialog = [[UIAlertView alloc] initWithTitle:@"Enter Text \n"
message:@"\n\n Keep it short and sweet"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
nameField = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 45.0, 245.0, 25.0)];
[nameField setBackgroundColor:[UIColor whiteColor]];
[dialog addSubview:nameField];
[dialog show];
}
Upvotes: 0
Views: 5951
Reputation: 318884
Use the provided API instead this hack. Instead of adding your own text field (which was never actually supported), set the alert view's alertViewStyle
to UIAlertViewStylePlainTextInput
. This will give you a supported text entry field in the alert view.
Upvotes: 2