From cb06c436cfd125efdd4efd71f1c87253104fb00e Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sat, 17 Jun 2017 11:42:27 -0500 Subject: [PATCH] constraint-based layout --- ui/MainView.m | 5 ----- ui/MainViewController.m | 43 +++++++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/ui/MainView.m b/ui/MainView.m index 6130c3e..9abf1ff 100644 --- a/ui/MainView.m +++ b/ui/MainView.m @@ -5,11 +5,6 @@ - (instancetype)initWithFrame:(NSRect)frameRect { NSLog(@"[MainView] initWithFrame: %@", NSStringFromRect(frameRect)); self = [super initWithFrame:frameRect]; - - // NSTextField *textField = [[NSTextField alloc] init]; - // [self addSubview:textField]; - // textField.translatesAutoresizingMaskIntoConstraints = NO; - return self; } diff --git a/ui/MainViewController.m b/ui/MainViewController.m index 8e27459..2db7001 100644 --- a/ui/MainViewController.m +++ b/ui/MainViewController.m @@ -1,32 +1,40 @@ #import "MainViewController.h" -#import #import "MainView.h" -@implementation MainViewController { - NSButton *firstButton; -} +@interface MainViewController () + +@property (nonatomic, strong) NSButton *selectDirectoryButton; + +@end + +@implementation MainViewController - (void) loadView { NSLog(@"[MainViewController] loadView"); - self.view = [[MainView alloc] initWithFrame:NSMakeRect(0, 0, 640, 480)]; + self.view = [[MainView alloc] init]; } - (void) viewDidLoad { NSLog(@"[MainViewController] viewDidLoad"); [super viewDidLoad]; - firstButton = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 120, 20)]; - [firstButton setButtonType:NSToggleButton]; - [firstButton setTitle:@"fart"]; + [self.view.widthAnchor constraintGreaterThanOrEqualToConstant:640.0].active = YES; + [self.view.heightAnchor constraintGreaterThanOrEqualToConstant:480.0].active = YES; - int i=0; - unsigned int mc = 0; - Method * mlist = class_copyMethodList(object_getClass(firstButton), &mc); - NSLog(@"%d methods", mc); - for(i=0;i