Reputation: 14611
Update: I ended up implementing the code below into it's own method and then called it from viewDidLayoutSubviews
and willAnimateRotationToInterfaceOrientation
. Doing it from viewDidAppear
(as suggested) would not resize the view when returning from a segue.
I have a UIView defined in a storyboard which I'm using for a header view on my UIViewController. I have a constant in my code for all header views to be 80 units high. I have a tag on the storyboard header view of 200. I thought I could use this tag to get the view, modify the height of the underlying CGRect, and then re-set the header view to the modified CGRect. That doesn't seem to affect the height however. What am I missing?
- (void)viewDidLoad
{
UIView *header = [self.view viewWithTag:200];
CGRect hrect = [header frame];
hrect.size.height = HEADER_HEIGHT;
[header setFrame:hrect];
...
Upvotes: 0
Views: 2159
Reputation: 6432
The problem is that you're using the tag as an NSString. The tag
property is an NSInteger. Try doing the following:
- (void)viewDidLoad
{
UIView *header = [self.view viewWithTag:200];// give the tag as an int
CGRect hrect = [header frame];
hrect.size.height = HEADER_HEIGHT;
[header setFrame:hrect];
...
Also, make sure the tag you defined in the Storyboard is also 200
and not @"200".
Hope this helps!
Upvotes: 1