views:

50

answers:

1

Have a nib file with a UISearchBar on top and a UITableView.

wann add an button and some text on top of the UISearchBar's input. so i made (in viewWillAppear):

[searchBar setFrame:CGRectMake(0, 0, 320, 90)];

works fine so far (except the position of the input needs to be vertically aligned to the bottom and not to center, any hints on that?).

but the tableView's content is now overlapped with the searchBar. thought i could fix that with:

[self.tableView setFrame:CGRectMake(0, 70, 320, 300)];

this has no effect. (i debugged a little bit around, and it seems i can't edit the origin of the searchBar either).

i can get self.tableView.frame.origin.x (y, width, height). but i cant modify it.

please point me in the right direction. feel a little bit lost on that topic (customizing color, style, alignment, position, size of UI elements).

A: 

You can set the frame components (x, y, width, height) but it's not immediately obvious how to do so. Since the property is for the 'frame' you can only edit the whole frame at once, so here's how to do it:

CGRect newFrame = self.tableView.frame;
newFrame.origin.x = desired_x_value;
self.tableView.frame = newFrame;
jhabbott
He is setting the `frame` property as a whole using `setFrame:`
Rengers
true. seems odd because the height of the UISearchBar is editable, as you know.
fetzig