All I need is to view a UIView
controller in same storyboard file manually with code. I use storyboard to make all forms and connections. My application starts in navigation controller, which provides me access to UIView
(LoginViewController
) and then it goes to tab bar controller, which provides 4 UIViews
. According to every UIView
I have .h
and .m
files. I know about segue method, it is simple, but I need manual method. Maybe I am doing something wrong.
I was trying to use this method for pushing view controller in IBAction
:
[self.view pushViewController:LoginViewController animated:YES];
But it makes an error:
Unexpected interface name ‘LoginViewController’: expected expression
It took a lot of time to figure out what is wrong, but I had not succeed.
Here is my RollEnemyController.m
file:
// RollEnemyController.m
#import "RollEnemyController.h"
#import "LoginViewController.h"
@implementation RollEnemyController;
@synthesize AttackButtonPressed;
- (IBAction)AttackButtonPressed:(id)sender {
LoginViewController* controller = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
[self.view pushViewController:controller];
}
@end
And this is header file:
// RollEnemyController.h
#import <UIKit/UIKit.h>
@interface RollEnemyController : UIViewController
- (IBAction)RollButtonPressed:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *AttackButtonPressed;
@end
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…