0

我正在尝试从 UIAlertView 按钮通过 presentModalViewController 调用视图。代码如下,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

任何帮助表示赞赏。

4

2 回答 2

0

只需尝试使用不同的导航控制器:

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

}

希望这会奏效..

于 2011-03-31T10:57:09.377 回答
0

可能是您试图从不是 viewController 的东西调用 presentModalViewController?例如视图。

于 2010-03-13T23:26:12.043 回答