Dodałem kod UIAlertController pokazujący pola tekstowe logowania i hasła, działa on na iOS 8, ale w systemie iOS 9 nie działa. Na Pola tekstowe kurczy, jak pokazano na rysunku poniżej UIAlertController nie działa w systemie iOS 9
Kod Staram się następująco:
- (void)toggleLoginLdap:(UIViewController *)currentVC
{
if ([UIAlertController class])
{
self.alertController= [UIAlertController
alertControllerWithTitle:@"Title of Msg"
message:@"Hello"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action){
NSString *userName = self.alertController.textFields[0].text;
NSString *password = self.alertController.textFields[1].text;
}];
UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
[self.alertController dismissViewControllerAnimated:YES completion:nil];
}];
[self.alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"Username/Email";
//textField.preservesSuperviewLayoutMargins = YES;
textField.autoresizesSubviews = YES;
}];
[self.alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"Password";
textField.secureTextEntry = YES;
}];
//alertController.view.autoresizesSubviews = YES;
[self.alertController addAction:ok];
[self.alertController addAction:cancel];
[currentVC presentViewController:self.alertController animated:YES completion:nil];
}
również próbował pokazać na rootviewcontroller ale bez powodzenia, sam kod działa na iOS 8. Projekt jest stary i wsparcie dla iOS 5. Każda pomoc zostanie doceniona. Dzięki.
więc Pola tekstowe powinny być w układzie pionowym lub poziomym układzie? –
Po prostu wypróbowałem twój kod. To działa dobrze. gdzie wywołujesz tę metodę toggleLoginLdap? –
Układ poziomy (jeden drugi poniżej), i działa również dla mnie w nowym projekcie demonstracyjnym, ale nie działa w moim starym projekcie (który jest tworzony w poprzedniej wersji xcode). –