Change Default Scrolling Behavior of Uitableview Section Header

How to dynamically change UITableView section header with scrolling. Or how to add a button to table section header?

Creating a simple subclass of UITableViewHeaderFooterView helped. It kept all the standard behavior and visuals, while I just added a button on top.

Ungrouping UITableView Section Header when Header is top of view

I am not completely sure I follow what you are trying to accomplish, but please allow me to attempt to infer and feel free to provide clarifications. I like the table view practice :)

As I understand it:

1) You want the white view, the red view, and the table cells beneath the red view to scroll upward from the default position

2) You want the white view to scroll out of visibility

3) You want the red view to float at the top while the cells scroll beneath it

4) You currently have the white view as a table header, the red view as a section header, and the gray area are table cells

Sounds like a cool app!

Why not use 2 table sections:

1) Drop the table header

2) Set the white view in cell 0 section 0 of the table view.

3) Set table delegate methods so section 0 will have a nil header with 0 height

3.5) Also set the table delegate methods so section 1 will be your main table

4) Use UITableViewStylePlain so section 1 header will float at the top

Is this the desired functionality?

how to scroll uitableview, and section header in the top, visible and scroll to

UITableViewStyleGrouped = The section headers and footers do not float.

UITableViewStylePlain = Any section headers or footers are displayed as inline separators and float when the table view is scrolled

You just change the UITableViewStyle to UITableViewStylePlain

Then to scroll to particular row and section programatically you could use this below UITableViewMethod method.

//Scroll to First row in 2 section
[yourTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1]
atScrollPosition:UITableViewScrollPositionTop animated:YES];

Sample Image
Sample Image

Apple Documentation

how can i make headerView scroll (not stay on the top of the tableview ) accompanying with UItableViewCell when i was scrolling tableview

subclass the UITableView and override this method

- (BOOL)allowsHeaderViewsToFloat{
return NO;
}

same for footer

- (BOOL)allowsFooterViewToFloat{
return NO;
}

But I think that this is a private API ... You will not be able to submit it to the AppStore

If you will upload it to the AppStore; Then you have two other options

  1. Adding a normal cell instead of the section header
  2. If you have only one section, then you can simply use table header instead of section header

How to get a custom section header's background to respond to scrolling in table view

You can put your label inside a custom subclass of UITableViewHeaderFooterView which does it automatically for you,

Apologies, I only know Swift, but here are the steps explained:

  1. Create your custom header class:
    Sample Image

  2. Next, register it to your tableview in viewDidLoad:
    Sample Image

  3. And, finally use it inside your viewForHeaderInSection:
    Sample Image

Basically, create a custom subclass of UITableViewHeaderFooterView (in code or using nib), configure and add your label as a subview to the header's contentView, register the custom header to your tableview, and then call it in the delegate method

UITableView sections headers don't scroll synchronously

Answer by caram in the RubyMotion Motion forum

If you inherit from UITableViewController, self.view is already a tableView, so
you end up with 2 tableView. Just delete @table = UITableView.alloc.init...

http://community.rubymotion.com/t/uitableview-sections-headers-dont-scroll-synchronously/525



Related Topics



Leave a reply



Submit