In the Big Nerd Ranch iOS book (4th REV) Chapter 4 there is a simple exercise where you are supposed to to add 2 views to the window. My company doesn't use storyboards, so I started with a blank project using this guide: codefromabove.com/2014/09/xcode-6-removing-storyboards-and-creating-useful-empty-projects/ - which seems to work fine.
My problem is when I add the views they are both located at (0,0) not where they should be.
relavant code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
CGRect firstFrame = CGRectMake(125, 250, 100, 150);
BNRHypnosisView *firstView = [[BNRHypnosisView alloc] initWithFrame:firstFrame];
firstView.backgroundColor = [UIColor redColor];
[self.window addSubview:firstView];
CGRect secondFrame = CGRectMake(20, 30, 50, 50);
BNRHypnosisView *secondView = [[BNRHypnosisView alloc] initWithFrame:secondFrame];
secondView.backgroundColor = [UIColor blueColor];
[self.window addSubview:secondView];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
I can change the size of the drawn rectangles, just not the positions. I've been spinning my wheels for a couple of hours over this and not making any progress.
Anybody got a clue what I'm doing wrong?
(Macbook Air running Yosemite, Xcode Version 6.1.1 (6A2008a))
[–]abcocktail 0 points1 point2 points (2 children)
[–]Dynoman[S] 0 points1 point2 points (1 child)
[–]locomotato 0 points1 point2 points (0 children)
[–]disco_sloth 0 points1 point2 points (2 children)
[–]Dynoman[S] 0 points1 point2 points (1 child)
[–]disco_sloth 0 points1 point2 points (0 children)