views:

419

answers:

1

I can access and show self.view and see the frame in the log but when I try to access self.view.frame I get null. Below is the log output of

NSLog(@"Show self.view:%@",self.view);
NSLog(@"Show self.view.frame:%@",self.view.frame);

-

2010-03-28 11:08:43.373 vivmed_CD_Tab[20356:207] Show self.view:<UITableView: 0x4001600; frame = (0 0; 320 583); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x3b21270>>
2010-03-28 11:08:43.373 vivmed_CD_Tab[20356:207] Show self.view.frame:(null)

Can anyone explain why self.view.frame is null but self.view shows a frame? My goal is to change the frame size.

Cheers, Grant

+3  A: 

One problem in the code you've posted is that you're printing the frame (a CGRect) as an object, which won't work. Try:

NSLog(@"Show self.view.frame: %u", self.view.frame);  // as a pointer

NSLog(@"Show self.view.frame: %@", NSStringFromCGRect(self.view.frame));  // as a string
Sixten Otto
That's right! The first two fields of the CGRect would be zero, so the Obj-C runtime interprets it as an object with a null class pointer. If the frame had a different origin, you'd be crashing.
codewarrior