这是我的AppDelegate.m文件:
#import "AppDelegate.h"
#import "LoginViewController.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
self.viewController = [[LoginViewController alloc] initWithNibName:@"LoginWindowController" bundle:nil];
[self.window setContentView:[self.viewController view]];
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag {
[self.window makeKeyAndOrderFront:self];
return YES;
}
@end
这是我的LoginViewController.m:
#import "LoginViewController.h"
@interface LoginViewController ()
@end
@implementation LoginViewController
@synthesize usernameField;
@synthesize passwordField;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Initialization code here.
}
return self;
}
- (IBAction)loginPressed:(NSButton *)sender
{
NSLog(@"Username = %@", [self.usernameField stringValue]);
NSLog(@"Password = %@", [self.passwordField stringValue]);
}
@end
如何在按下登录按钮时切换回主视图?哪个在自动创建的文件MainMenu.xib中。网上的大多数教程都是针对iOS的,在处理视图方面略有不同。我怎样才能为视图过渡设置动画?