Ich habe ein altes Xcode-Projekt, das für iOS 6 und höher ausgerichtet ist. Ich öffnete sie vor kurzem in Xcode bis 6 und lief in iPhone 6 Simulator für iOS 8. Wenn ich diese Aktion versuchtUIAlertView Vs UIAlertController - keine Tastatur in iOS 8
UIAlertView* dialog = [[UIAlertView alloc] initWithTitle:@"Enter Folder Name"
message:@"Keep it short and sweet"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
dialog.alertViewStyle = UIAlertViewStylePlainTextInput;
dialog.tag = 400;
[dialog show];
ich ein Pop-up-Fenster bekommen, aber wenn ich auf das Textfeld klicken, keine Tastatur kommt . Ich habe gegoogelt und gelesen, dass ich stattdessen UIAlertController verwenden muss. Da ich iOS 6, 7 Versionen auch unterstützen muss, habe ich meinen Code so geändert.
if ([UIAlertController class])
{
// use UIAlertController
UIAlertController *alert= [UIAlertController
alertControllerWithTitle:@"Enter Folder Name"
message:@"Keep it short and sweet"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action){
//Do Some action here
UITextField *textField = alert.textFields[0];
NSLog(@"text was %@", textField.text);
}];
UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
NSLog(@"cancel btn");
[alert dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:ok];
[alert addAction:cancel];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"folder name";
textField.keyboardType = UIKeyboardTypeDefault;
}];
[self presentViewController:alert animated:YES completion:nil];
}
else
{
// use UIAlertView
UIAlertView* dialog = [[UIAlertView alloc] initWithTitle:@"Enter Folder Name"
message:@"Keep it short and sweet"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
dialog.alertViewStyle = UIAlertViewStylePlainTextInput;
dialog.tag = 400;
[dialog show];
}
Auch wenn ich versuche, die gleiche Aktion NO Tastatur angezeigt wird.
Ist das ein Fehler im Xcode 6-Simulator oder mache ich etwas falsch?
Try „Command“ + „K“ drücken, kann iOS Hardware-Tastatur erkennt so ist es nicht zeigt die Tastatur –
In Simulator Menüoption Hardware -> Tastatur -> Toggle Software-Tastatur – yazh