UIAlertView нажалButtonAtIndex с presentModalViewController - PullRequest
0 голосов
/ 14 марта 2010

Я пытаюсь вызвать представление через presentModalViewController с помощью кнопки UIAlertView. Код ниже, NSlog отображается в консоли, поэтому я знаю, что выполнение кода действительно достигает этой точки. Также нет ошибок или чего-либо отображенного:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

if (buttonIndex != [alertView cancelButtonIndex])
{
    NSLog(@" The username is: %@ AND the password is: %@ ",textField.text,passTextField.text);

 // do some logic in here later 

    CompanyViewController *companyViewController = [[[CompanyViewController alloc] initWithNibName:@"CompanyViewController" bundle:nil] autorelease];  
    [self presentModalViewController:companyViewController animated:YES];
}
[textField resignFirstResponder];
[passTextField resignFirstResponder];

}

***** Редактировать: описанный выше метод принадлежит UIViewController. Ниже приведен файл интерфейса:

@interface testingViewController : UIViewController  <UITextFieldDelegate>
{
UITextField *textField;
UITextField *passTextField;
}
@property (nonatomic, retain) UITextField *textField;
@property (nonatomic, retain) UITextField *passTextField;
@property (readonly) NSString *enteredText;
@property (readonly) NSString *enteredPassword;

@end

Любая помощь приветствуется.

Ответы [ 2 ]

0 голосов
/ 31 марта 2011

Просто попробуйте использовать что-то другое с Navigation Controller:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

  if (buttonIndex != [alertView cancelButtonIndex])
  {

      CompanyViewController *companyViewController = [[CompanyViewController alloc] init];
      UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:companyViewController];

      [self.navigationController presentModalViewController:navController animated:YES];
      [navController release];
  }

}

Надеюсь, что это сработает ..

0 голосов
/ 14 марта 2010

Может быть, вы пытаетесь вызвать presentModalViewController из чего-то, что не является viewController? Например, просмотр.

...