我正在尝试通过来自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
感谢任何帮助。
答案 0 :(得分:0)
可能是你试图从不是viewController的东西调用presentModalViewController?例如,视图。
答案 1 :(得分: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];
}
}
希望能有效..