I'm using a UITableViewController, and with 2 sections.
One section does use a Header and the other one doesn't.
The header view of one section, has an UITextField, an UIButton and an UISegmentedControl, all with AutoLayout using PureLayout Framework.
When I scroll, the Header view stays fixed in the top (just as a normal header would do).
Now, When I click on the Button, I call a method to update an User, (taking the text from the UITextField) and as soon as I get the data, I reload the data from the table.
It is here, when the UIView used as a Header, jumps to the top of the screen, or if it's fixed on the top, disappears until I move the table the Header appears correctly.
Don't know what really it's happening, any ideas guys?
Thanks!
Try to add in viewDidLoad: self.automaticallyAdjustsScrollViewInsets = NO;
I have issue when in header was an image, and when i scroll header remain, but table content goes under it. I solve this issue with change style from Plain to Grouped. But i think this is does't help you, but maybe...Also check your creating tableView cells, if it they're custom - register nib of cell in viewDidLoad.
Related
I have a tableView and I have a UIView as the tableView header. I want the header to move up the screen when I scroll down and act just like any normal cell. But when I have reached the top of the view, where if I scroll up it will just bounce back, I want the tableView header to stick to the top.
One example is like the Facebook app headers. They scroll when you scroll, but if you're at the top of the page and you scroll up, they wont scroll down, they stay stuck to the top.
How do I achieve this?
If you're using a normal tableView (not grouped style) and you only have one section, you can accomplish this by using the section header instead. The default behaviour of this type of tableView is as you described. You'll just have to provide a custom view for the section header that looks like your cell.
If this isn't a possibility, you'll need to take advantage of tableView being a subclass of scrollView, and implement the scrollViewDidScroll delegate method to check content offsets etc.
I have UITableView with SVPullToRefresh. Above this UITableView I have a view with UITextField, buttons etc.
(Ex: .
I would like to implement such thing: when I scroll down my tableView I would like to scroll this header too. (This could be easy created with Table header, but as I said I am using pull to refresh). And when I start to scroll up - immediately appeared. Sorry for my poor english. Help me out.
P.S. I am using autolayout
I have created a table view header using the answer here.
My problem is that when creating the header this way, it does not "stick" to the top of my UITableView when scrolling down. If I create my header in code inside of viewForHeader then it does stick.
How can I get my header to stick to the top while scrolling if I create it in storyboard? 2 other askers here and here asked this question and never got an answer.
And yes my UITableView is already plain style, not grouped.
rdelmar's comment helped me understand the reasoning behind it not working. Here is what I did in practice to fix the problem:
I had to drag the header view in storyboard down by where the first responder is. You'll notice you can't actually drag the header view down on the view itself, you'll have to drag the element down from the document outline.
I also had to implement viewForHeaderInSection (returning the header view that I made an outlet) and heightForHeaderInSection.
Every time you want to edit the view via storyboard, you'll have to drag it back up to edit it, then drag it back down so it works correctly.
Just drag tableview cell first, then your view for the header above. And afterward, remove the unneeded cell. The header will remember its position.
Take this about page for Things:
I'm having trouble creating something similar. I just want a UITableView under a UIView with a UIImageView and a UILabel in it.
If I use a UIViewController and so I can position the UITableView downward, I get this error: "Static table views are only valid when embedded in UITableViewController instances."
If I use a UITableViewController with a grouped style and use contentInset on self.tableView to move it down ([self.tableView setContentInset:UIEdgeInsetsMake(150,0,0,0)];) I can't figure out how to place a view above it. If I try to attach anything to self.view it crashes (obviously). Same happens if I attach anything to self.tableView.
I then tried making the UIView the header of my UITableView section (I only need one section) but I can't get it to move up enough. It just sits inside the UITableView almost.
How do I have a UITableView (grouped style) exist with a UIView above it?
This can be achieved easily using the tableHeaderView property of UITableView. If you are using Interface Builder (which it looks like you are), then you can just drag a UIView above the table view and it will be set as the table's header view. All you need is a UITableViewController; no need for UIViewController and manually laying it out.
That's because the view probably isn't placed on top of the table but rather within the table's section 0 header. Or, even more likely, the view in question is just a regular UITableViewCell with a 0 alpha background.
Either of these options would allow the top view to be scrolled out of frame as the user scrolls under every condition.
I recommend [MDAboutController] (https://github.com/mochidev/MDAboutController)
It's easy to integrate and you don't have to waste any time configuring the UITableView.
I have two Scenes in my Storyboard that are nearly identical. Both are UITableViewControllers. Both have header and footer views. The header views have a UISearchBar and the footer views have a UIView that contains a UITextField. Each have only one prototype cell. One is prototyped as a "Basic" cell and the other is prototyped as "Right Detail" cell.
Here's the problem. When I click the UITextField in the footer view on the first scene, the table resizes automatically so that the bottom of the table is at the top of the keyboard. This allows me to scroll the table up so the footer view shows and the user is able to see what they're typing. The other scene will not automatically resize the UITableView so the UITableView cannot scroll the footer view to where it can be seen and the UITextField is hidden under the keyboard. I can't even manually scroll the table far enough since the footer is always at the bottom of the UITableView.
A little added info. The scene that works has many rows of data while the one that doesn't work only has a couple. I tried adding a number of rows until the table had enough to enable scrolling and it doesn't fix the problem.
I have checked everything I can think of and I can't see anything that would allow one of the views to let the UITableView to automatically resize to work with the keyboard and the other not. I must have overlooked something but I can't seem to find it.
Any help will be greatly appreciated!
Rob
I thought this problem was caused by copy-and-pasting from one view to another, but I had the same problem once I'd (in theory) fixed it.
The answer for me turned out to be simple: I hadn't called [super viewWillAppear:animated] in my UITableViewController subclass' viewWillAppear: implementation. Make sure you've got a call to the superclass' method and hopefully the problem will go away.
I am guessing the frame of the tableview is not being resized to the smaller size in the second case.
Print out the frame and content sizes in both the cases once its loaded, that should help you see if there is an issue.