PushViewController单击按钮

时间:2012-09-21 11:42:44

标签: xcode button pushviewcontroller

PushViewController单击按钮

这是我的代码:

ViewController.h

import < UIKit/UIKit.h>

@interface StaffLoginViewController : UIViewController
@property (retain, nonatomic) IBOutlet UITextField *StaffUsername;
@property (retain, nonatomic) IBOutlet UITextField *StaffPassword;
- (IBAction)LoginClicked:(id)sender;
@property (nonatomic, retain) NSArray *arrayLogin;
- (IBAction)ResignKeyboardClicked:(id)sender;

@end

ViewController.m

- (IBAction)LoginClicked:(id)sender{

ViewController *view = [[ViewController alloc] initWithNibName:@"ViewController"     bundle:nil];
[self presentModalViewController:view animated:YES];
}

我只有modalViewController的代码。请帮忙!感谢:)

1 个答案:

答案 0 :(得分:0)

而不是

[self presentModalViewController:view animated:YES];

你应该使用

[self.navigationController pushViewController:view animated:YES];

但是,但是,你也应该有NavigationController,例如

AppDelegate.m ......

StaffLoginViewController *vc = [[StaffLoginViewController alloc] init];
self.navController = [[UINavigationController alloc] initWithRootViewController:vc];
self.window.rootViewController = self.navController;
[self.window makeKeyAndVisible];

.......