Okay so i have a very basic app with a view in it with one button. i have the controller set to only allow landscape. My problem is that after it is initialized, and then i click my button (which only has a log statement) , is different than the log statements i have at the end of my init.
I start the app in landscape mode on my simulator (same results on device though). Its like once i assign it , it just switches back. I tried this statement self.frame = CGRectMake(0, 0, 1024, 768);
in my buttonClicked method, but that just distorted and shifted it.
- (id)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame]))
{
//BUTTONS
attributesButton = [UIButton buttonWithType:UIButtonTypeCustom];
attributesButton.frame = CGRectMake(self.frame.size.width - buttonPadding - 35, self.frame.size.height/2 -22 -150, 35, 35);
[attributesButton setBackgroundImage:[UIImage imageNamed:@"loadIcon.png"] forState:UIControlStateNormal];
[attributesButton addTarget:self action:@selector(attributesButtonClicked)
forControlEvents:UIControlEventTouchUpInside];
[attributesButton setTitle:@"Attr" forState:UIControlStateNormal];
[self addSubview:attributesButton];
NSLog(@"Width: %f",self.frame.size.width);
NSLog(@"Height: %f",self.frame.size.height);
}
return self;
}
-(void)attributesButtonClicked
{
NSLog(@"Width: %f",self.frame.size.width);
NSLog(@"Height: %f",self.frame.size.height);
}
So that is my init. Sorry it looks so terrible im not sure why. My view controller:
- (void)loadView
{
NSLog(@"myViewController: loadView");
myView = [[myView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)];
self.view = myView;
}
Now this is the part that gets me, the log statements.
2010-08-27 15:16:55.242 tester[8703:40b] myViewController: loadView
2010-08-27 15:16:55.262 tester[8703:40b] Width: 1024.000000
2010-08-27 15:16:55.262 tester[8703:40b] Height: 768.000000
CLICK MY BUTTON HERE
2010-08-27 15:17:05.689 tester[8703:40b] Width: 748.000000
2010-08-27 15:17:05.689 tester[8703:40b] Height: 1024.000000