Modify the sidebar of UITableView? - iphone

my UITableView has a bunch of sections and therefore displays a sidebar, which let's you scroll through the sections.
The problem is: I have a UISearchBar in the header of the UITableView, and the sidebar covers the clear (x) button of the UISearchBar.
Can I modify the sidebar to add margin or at least remove it completely? I couldn't find anything on the sidebar on the Apple Developer site.

Do you have this view made in a xib file is the question?? If you do you should be able to resize the table view to do however big you want it. Here is a link on the apple developer site that has a lot of helpful information about UITableViews and UITableCells:
http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html#//apple_ref/doc/uid/TP40007451-CH7-SW1

The UISearchBar is the headerView of the TableView. I want the strange stuff on the side moved down by the height of the SearchBar, or completely removed.
I figured out, that you can remove the bar with
self.tableView.sectionIndexMinimumDisplayRowCount = 1337;
At least, if you have less than 1337 sections. However, if anyone knows how I access the object which represents the index on the right directly to resize it and move it down, please let me know.
Image of the cause: http://img59.imageshack.us/img59/5397/bildschirmfoto20101121us.png
I think it's a bug in UITableView, so I'm going to report it to Apple.

Related

How to lay out scrollable iPhone view

I need advice on the most pragmatic way to layout the following view. As you can see from the image attached, I have a static logo and text that appears at the top of the view, followed by a variable number of items.
Initially, I was going to use a TableView for the variable number of items, that way I would be able to load any given number of cells at runtime.
My problem is that if I drop a tableView onto this view below my static logo and text, when the user scrolls, the static logo and text will remain fixed. I need both the static logo/text AND the tableView to scroll up.
My next inclination is to use a scrollView, inside which I would place my tableView and static logo.
Is this the most pragmatic way to approach the problem? If so, will there be usability issues when scrolling the scrollView vs scrolling the tableView? In my mind this could get messy.
Any advice on the best way to approach this is greatly appreciated.
Using a table view inside of a scroll view is a bad idea and warned against by Apple in their docs. Basically the internal gesture recognizers can conflict and create a clunky user experience. The best path forward would be to go with the tableview (which is a subclass of scroll view) and have two different kinds of cells– one for the logo and one for the repeating contents at the bottom. Make the first cell the logo and adjust the table view's settings to format it to your heart's content.

IOS IPhone label moving when screen scrolled

I appreciate that this is probably something people will need code samples to properly answer but unfortunately I don't have them to hand at the moment so I'm asking for peoples experiences and whether they've seen anything like this before.
I have a view with a UITableView in it, there are a bunch of cells and on this particular view if I scroll the screen down then the label that's in the last cell superimposes itself on top of the label in the first cell.
It only happens on this one view where the first and last cells appear or don't appear in the UITableView depending on whether certain values are in a JSON feed.
If both cells are in the UITableView then when you scroll, the label of the bottom one appears on top of the top one. The bottom cell's label is still in place, as is the top one - just with the bottom one on top of it!
So, has anyone seen anything like this and if so is there's an obvious thing I'm doing wrong that this type of occurrence is a symptom of?
How to look for the cell being dequeued?
Check out [UITableViewCell prepareForReuse] and that's where you can remove previously inserted subview(s) before adding new ones.
Here's the Apple documentation:
http://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewCell_Class/Reference/Reference.html#//apple_ref/occ/instm/UITableViewCell/prepareForReuse

Left area of section in iPhone TableView

I have a section where I would like to customize the left area of a section a TableView - a bit like viewForHeaderInSection.
I have thought at using a cell for the section instead, but it would be a lot of nitty-gritty.
If I understand your question correctly, you want to customise the left-hand-side of some, or every cell in a UITableView? Then you need to make create your own custom table view cells. I normally make these cells in Interface Builder; this post helped me out. See also the Customizing Cells section of Apple's Table View Programming Guide for iOS.
I read your question to mean that there is one custom element to the left of a bunch of cells. The only way I know of offhand is to use a cell as you describe and then have a left view and a tableview inside of it.

Adding a UISearchBar on a UITableView

I have an UITableView and I did put an UISearchbar on it. What I want to achieve is that if a user is going to scroll i want the UISearchbar element to be fixed on the top, plus I want the first row of the UITableView fixed as well. Is there any sample code for this ?
So far every sample I found the UISearchbar wasn't fixed at the top, if you scroll it disappears. One way to get the UISearchbar element fixed could be, if I put an UIView under both elements (UITableView and UISearchbar) and put those two consecutively among themselves (just a thought of me don't know if this actually is working). However i'm not sure if this is the appropriate way to go and it also wouldn't fix that I want the first row fixed as well.
I'm kinda new to this stuff would be glad if someone could point me in the right direction, thank you.
For the fixed search bar: just make it a sibling of the tableView.
For the fixed first row: maybe make it the section header and have only 1 section, or make it a sibling view.

UITableView Won't Scroll In Certain Conditions

My app has a set of categories. A category can have sub-categories.
DirectoryCategoryController is the first screen, displaying all the top-level categories. Works great. When you tap a cell, if the category selected has sub-categories, I instantiate a new instance of DirectoryCategoryController and push it to display the sub-categories. From there, you tap a sub-category and see the contents.
The problem is that while the top level works fine, when I tap in and see the sub-categories, the table view won't scroll. The search bar takes touches, the table cells take touches but up and down scrolling does not work, like the table view is vertically frozen in space.
If I tap the search bar and hit cancel or if I go into a sub-categories contents and then hit back, the very same table view that didn't scroll works just fine.
Also, if the table view has more items than fit on the screen (about anything bigger than 8 in this layout), everything works.
Very odd problem ; kinda blowing my mind. Any insight?
So, I figured this out and thought I would answer as a reference.
At this point, I think it may be an iPhone OS bug and I'm filing a RADAR.
A UIScrollView, of which UITableView is a subclass, will not attempt to scroll if everything fits on one screen.
In my case, it appears the scroll view thought everything fit (it was very close) but it didn't. Actually, if you removed the UISearchBar from the UITableView, everything would have fit and it wouldn't need to scroll. My guess is that it's incorrectly determining the geometry when the UISearchBar is attached.
Anyway, the work-around was to add this:
[self.tableView setAlwaysBounceVertical:YES];
The odd thing was that when another view was pushed and then popped, the vertical bounce worked fine, furthering my suspicions it's an iPhone bug.
I noticed the same thing when using A UITableView with a UISearchBar as the header view, as configured in Interface Builder in Xcode 4.3.1. In my viewDidLoadMethod, I added the following code and it fixed the problem for me:
self.contactsTable.bounces = YES;
I believe that it's a bug that disables the bounces property, but it can be fixed by re-enabling it.