I have a simple application that I am making, following The Big Nerd Ranch iOS book.
I am getting this peculiar response from a CGRect where it doesn't leave the origin of the simulator no matter what values are entered.
I create a simple UIView class called HypnosisView and it doesn't have any code in it.
Here is the code I am using in AppDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
CGRect firstFrame = CGRectMake(160, 240, 100, 150);
HypnosisView *firstView = [[HypnosisView alloc] initWithFrame:firstFrame];
firstView.backgroundColor = [UIColor redColor];
[self.window addSubview:firstView];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
And here is what is created:
I am hoping this is another quirk of Xcode 6 and not some silly mistake I have made, however I've been looking at it for a good couple of hours and I'm sick of it.
EDIT: I think I figured out my problem, however it raises a side question.
#import <UIKit/UIKit.h>
@interface HypnosisView : UIView
@property (nonatomic) CGRect frame;
@end
This Was the code in my HypnosisView.h file and the superclass obviously has it's own version of initWithFrame.
If you don't overwrite the superclass's functions, can they call your instance variables by accident?
For example here we have the example function:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
}
Would self ultimately equal the instance variable "frame"? Even though I never called the initWithFrame function so the super version should be out of scope?