views:

282

answers:

1

Hi,

I am trying to call a view via presentModalViewController from a UIAlertView button. The code is below, the NSlog is displayed in the console so I know that code execution is indeed reaching that point. Also, there are no errors or anything displayed:

- (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];

}

* Edit: The method above belongs to a UIViewController. Below is the interface file:

@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

Any help is appreciated.

A: 

It could be that you are trying to call presentModalViewController from something that is not a viewController? For example a View.

Benjamin Ortuzar
Hi, I just edited my question - thanks. The method belongs to a viewController.
Vivas