views:

24

answers:

1

I want to add a footer view to my gouped table view for now i have this:

NSLog(@"width:%f",self.view.frame.size.width);
        UILabel *lblInfo = [[UILabel alloc] initWithFrame:CGRectMake(50, 30,self.view.frame.size.width - 100, 70)];
        lblInfo.text = @"Hellow";
        [footerView addSubview:lblInfo];
        [lblInfo release];

which give me this result: http://img256.imageshack.us/i/schermafbeelding2010102t.png/ This is landscape and self.view is an pushed subview of the detailview of my splitcontrol. The nslog of the first: ->width: 703

If i turn (to portrait) it i get this result:http://img821.imageshack.us/i/schermafbeelding2010102.png/ The nslog of the second: -> width: 768

normally the two footer views should have a left & right margin of 50px...

What am i overseeing?

+1  A: 

You should set autoresizingMask:

lblInfo.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin;

You should also note to create the label with the footer's size:

UILabel *lblInfo = [[UILabel alloc] initWithFrame:CGRectMake(50, 30,footerView.frame.size.width - 100, 70)];
Aviad Ben Dov
This is equivalent to what you'd do in Interface Builder, in the size section of the inspector.
Aviad Ben Dov
wow didn't know that :) What is the | char? Is it the same like "or" ? I tried it but now i have this result: http://yfrog.com/5oschermafbeelding2010102p (so i am still not there)
meersmans
Is _footerView_ the same width as _self.view_, in your example? When you create your label, try creating it with _footerView.frame.size.width - 100_ for width instead.
Aviad Ben Dov
Just added: footerView.frame = CGRectMake(50, 30,self.view.frame.size.width - 100, 70); and still the same
meersmans
Not exactly what I meant - I updated my answer.
Aviad Ben Dov