xcode PushViewController 用于单击按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12529877/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PushViewController for a button click
提问by
PushViewController for a button click
PushViewController 用于单击按钮
Here's my code:
这是我的代码:
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];
}
I only have the code for modalViewController. Please help! Thanks:)
我只有 modalViewController 的代码。请帮忙!谢谢:)
采纳答案by NeverBe
Instead of
代替
[self presentModalViewController:view animated:YES];
you should use
你应该使用
[self.navigationController pushViewController:view animated:YES];
but, but, but you should have NavigationController as well, for example
但是,但是,但是你也应该有 NavigationController,例如
AppDelegate.m ......
AppDelegate.m ......
StaffLoginViewController *vc = [[StaffLoginViewController alloc] init];
self.navController = [[UINavigationController alloc] initWithRootViewController:vc];
self.window.rootViewController = self.navController;
[self.window makeKeyAndVisible];
.......
......