Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,672
6,212
Right now I'm trying to set up a table within a navigation controller.

I was a search bar as the table header.

Just below the table header I want two buttons side by side.

Below these two buttons I want the table to proceed as normal with sections and cells.

I managed to get everything set up except the two buttons side by side. My initial idea was to create a section with no cells, just a header, and replace the header with the two buttons, but it would appear that isn't possible because all you can return for a section header is a text label. So then I had the idea of creating a section with no header, just a single cell with the two buttons. The issue is, I don't want the cell to be visible. I want the two buttons appear to be floating between the table header (the search bar) and the typical sections and cells below it.

Why am I not just putting the two buttons in the header? Well, I also want the table view to scroll down just far enough that the search bar disappears. If I add the two buttons to my header, they scroll off the top along with my search bar, which I don't want.

Help would be greatly appreciated. Just ask if I didn't explain it well enough (do I need to draw a diagram of what I want?)

Edit: :D

Why is it that I always suddenly realize the solution after posting the question? Why can't it come moments before rather than moments after?

Oh well, here's what I did:

I set the table to have two sections.
The first section has no header and one cell, which has the hidden property turned on.
The second section has typical nothing special header and cells one would expect to see in an iPhone application.
The header of my table draws the two buttons below it's bounds. As a result, the empty space where the hidden cell is ends up being filled with my buttons :) And my table scrolls to the correct position.
 
If I add the two buttons to my header, they scroll off the top along with my search bar, which I don't want.
If you add them to the table, depending on how many rows you have, the could end up scrolling off anyways. What about adding a toolbar to the bottom of the page that contains the two buttons?
 
I didn't mean it wasan issue they could scroll off. I meant I have a function when the table first loads to hide the header by calling scroll to section 0 row 0 to top. Think like Notes where getting to the scroll bar requires scrolling up. My toolbar is already set up the way I'd like, adding more would probably crowd it.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.