I would like to add a UISegmentController in the top of my UITableViewController, just like in the AppStore.
I have tried googleing this but either I am search for the wrong things, or too view have written about this.
How can I do this, keeping it in the top with a different design than the UINavigationBar.
For style add segmentCont.segmentedControlStyle=7; which is same as the picture style.
It may not be a UITableViewController. It might be just a UIViewController with a segment control at the top of the XIB and a tableview placed underneath the segment control. That way, you could scroll the table view without scrolling the segment control.
I believe that is a custom header cell for the tableview. You should start by created a custom header with your segmented control inside that.
I think that's a ToolBar with UISegmentedControl or just UISegmentedControl and UITableView under it. You can place them (UISegmentedControl + UITableViewController) on UIScrollView and disable scroll for UITableView. You should make appropriate contentSize for your scrollview.
Related
Today I faced a weir bug in UITableView.
I have a UIViewController containing a UITableView. I also have a root viewcontroller, which will add the aforementioned UIViewController as a child.
Now when loaded, it shows a space between cells and the top border.
How can I fix that?
Try to deselect Adjust Scroll view insets option of the ComicsVC view controller.
First select ComicsVC item in the left window of your storyboard, then in the attributes inspector you will easily find this checkbox.
You have to set top position of UITableView to 0. Also you have to add constraints between UITableView and parent UIView.
This bug appears when you use translucent navigation bar.
That space shows up for grouped UITableViews, and is usually occupied by a section header. If you don't implement a section header, then the area will be blank.
If you don't have more than one section, go to the UITableView in the storyboard, show the properties, and change the style to Plain.
Hope this helps!
I am currently using the https://github.com/telly/TLYShyNavBar class to hide my nav bar when scrolling, it works great and is extremely simple to use. But I am using it on a table view controller so when I scroll up my section headers don't move and it looks like this.
How can I move up the section headers to the top of the screen. Or use a different way to move the nav bar when scrolling.
Thanks for the help in advance.
You could use the first TableViewCell as a custom navigation bar by adding buttons to the contentview contained in the TableViewCell. It would scroll up like any other TableViewCell. TableViewCells are mostly just a wrapper for a UIView. You can modify that UIView like any other UIView. Every TableViewCell has a property called contentview which is the main UIView in the Cell.
As an example, you could add a button to the first cell that sends the following message
[self.navigationController popViewControllerAnimated:YES];
You could call that button "Back"
https://developer.apple.com/library/IOs/documentation/UIKit/Reference/UITableViewCell_Class/index.html#//apple_ref/occ/instp/UITableViewCell/contentView
I found a solution for this!
The problem is that, the section header stays at the top value of the contentInset. Even though the navigation bar is out of view and the tableView is visible below, the contentInset will remain same.
You would have to modify the library to increase or decrease the top value of the contentInset, according to the scrolling offset. Try this out and you may post it as a pull request in github.
Hope this helps! :)
According to the answer at UITableView, make footer stay at bottom of screen?, which I verify:
In order to have a footer that stays put at the bottom of the screen,
and doesn't scroll with the table, then you can't use a table view
footer. You can't even use a UITableViewController, you'll need to
implement your view controller as a UIViewController. Then you add
your own table view as a subview. You'll also need to add your footer
as a subview of the view controller's view, not the table view. Make
sure you size the table view so its bottom is at the top of the footer
view.
but the problem is that my UITextField, inside my footer, is being hidden by the keyboard when user tries to type. So how do I keep the keyboard from hiding the UITextField? Throughout the app, I have been using TPKeyboardAvoiding. But in this case, where a UIScrollView/TPKeyboardAvoidingScrollView contains a UITableView and a UIView in vertical order, it does not work. I generally like TPKeyboardAvoiding because it’s so quick and easy. Any ideas how I might fix this issue?
The instruction that you quote is telling you to use a UIViewController, add a UITableView as a subview, then add a UITextField as a subview of the UIViewController NOT as a subview of the UITableView.
Let me draw it out for you:
Step 1:
Add a UITableView to your view controller
Step 2:
Add your UITextField subview (you can embed the UITextField in a UIView container if you like) as a subview of your UIViewController's view NOT your UITableView footer.
Step 3:
If depending on if your using frames or autolayout, you adjust the frame or autolayout constraint constant values for your UITextField subview when user tap on the text field.
Step 4:
Finally, the keyboard appears and the UITextField doesn't get obscured by the keyboard.
Just make sure your UITableView doesn't initialize it's own automatic scrolling for keyboard appearing. If you use UITableViewController then just subclass it and make sure you don't call it's viewWillAppear:. I didn't investigate which exactly method you should block without using UITableViewController, so, you should find out this yourself or somebody else would help.
I did similar in my own project where I wanted to have own scrolling of table view for keyboard appearing.
I would like to make a page like this (i.e. a fix segmented controller on the top, with a uitableview appending beneath it):
So, this is the way I did it: I have added a segmented controller in a uiviewcontroller, then I append a uitableview under it. Here is the diagram in the storyboard:
However, when it runs in the simulator, the header of the uitableview is abnormally tall.
I have no idea why it is like this. Am I going to a wrong direction? Thanks for any helps.
UPDATE:
This is the default setting of the uitableview. I didn't change any thing.
Select your view controller in storyboard. In the Attributes inspector, uncheck "Adjust Scroll View Insets" and uncheck "Under Top Bars".
You have placed Segment control in Tableview's header. But you had set some height to tableview section header via either xib or programmatically. That's why it leads to show this space.
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.