Is there a way to add custom views above and below a UITableView?
I'd like to have a custom header and a custom back button in the footer. What would be the best to do this?
I've started by subclassing UITableViewController and tried resizing the UITableView. In vain.
Tried adding a new main view to UITableViewController and adding the UITableView as a subview to it. Result: table view won't appear at all.
Tried adding the back button as a subview to the table view, but it will get scrolled this way.
Now I guess it would be the best to somehow replace the "original" header/footer, but is that possible?
Edit: Solved!
Using this tutorial, I've managed to add the required header and footer to the view using the Interface Builder.
Shouldn't the UITableView's tableHeaderView and tableFooterView properties do just what you want?
Ultimately I couldn't achieve what I wanted by code, but as noted in the edit of the original question, I was able to it using Interface Builder with the help of this tutorial.
Related
I am working on a swift project in Xcode right now and one of my view controllers is a UITableViewController. I used swift to alter the size of the table view in the controller so that it does not fill up the entire screen. However, I want to set a background image for the entire view controller which I am unable to do since XCode is not letting me add an image view between the table view controller and the table view. Is there any way to do it using swift? Thank you.
I think I can help out.
If you're using Apple's UITableViewController - does that mean you altered the tableView's height in the storyboard? I think a better solution is to just use a regular UIViewController, add a tableView with whatever height you want it inside a UIViewController's view.
Often times I would recommend steering away from using Apple's custom things because you lose flexibility. Just make your own custom thing instead!
UIViewController > View > TableView & UIImageView
Make sure your tableview has a clear background!
I started a project with storyboards and it has a lot of views, each one of them has the same header (with an image, company name and two buttons). I want to do this once in the main View, and make it reusable for the other views. It’s like a master view with a header and footer. How could i do this?
This is my first project starting from cero and I want to make it as organized as possible. What are the best practices using storyboards and MVC?
Thanks in advance.
There is no special way of doing this in storyboard.
But you can do it easily by making custom UIView.
Make a sub class of UIView and pust all common design in it.
Place a UIView on top of every UIViewController.UIView.
Now set this top UIView's class with your custom class in identity inspector.
All the best.
A primitive way to do it in storyboard is to define there your master view, select all of its elements, copy them and paste them into the other views.
You can subclass UIViewController to add a header to its view, and UITableViewController to set it as the tableview header.
I've made a custom class that consist in a customized animated toolbar instanced in all my views. It works well in classic UIview using [view addSubview:]. The bar stays between the tabbar and the view. But in my tableviewcontroller, it follows the cells when I swip them.
I don't have Xcode right here so I can't post any explicit code, but I'm just looking for a hint.
Thanks
PS: I've tried to search it over stack and Google, but I think I use the wrong keywords (not so good english :p)
Which view did you add your bar?
Try add it to the superview of the tableview instead of tableview itself.
I'm new to Xcode 4, and having some problems with TableView.
I have a ViewController which I dragged into a TableView.
I have the source model, and created an array,
but I don't know how to get the TableView to display the values.
I don't want to use a TableViewController, because I want the table to be smaller than the IPhone screen - but without it I don't know how to connect the TableView to a controller.
can someone provide me a good step-by-step explanation of how to do it?
thanks
A simple and efficient example of creating a TableView , here
declare your view controller as conforming to the UITableView delegate and datasource protocols
Connect the tableview's delegate and datasource outlets to your view controller in interface builder
implement the methods as described in the documentation.
Table view controllers give you a little extra in terms of editing mode and a few visual features on the table, but you can add a table view to a view managed by a standard view controller and be just fine.
If i understoof the question correctly to connect the smaller table to the code, you right click on the table in the interface builder and connect the delegate to the files owner it should work.
Otherwise if you check out http://www.geekylemon.com they have some really good tutorials
Cheers
I have this code linked to a button on a ViewController with a UITableView as subview:
-(IBAction)Action:(id)sender{
[tableView setContentSize:CGSizeMake(320, 1000)];
}
This makes tha tableView scrollable to the bottom so that I can use a couple of buttons I programatically added to the bottom. So far so good.
However, I want the tableView to be ok from the beginning, so I added the code inside viewDidLoad. Surprisingly, it doesn't work at all.
Could somebody give me a hand?
thanks!
If your datasource methods are being fired after viewDidLoad, the tableView content size will be reset when it's loaded. You'll need to make sure you've called reloadData for the table before the code above. If you're using a UITableViewController, the order the methods are called is:
viewDidLoad
ViewWillAppear:
<your datasource methods>
ViewDidAppear:
However, if you want buttons at the end of table, you should put them in the tableFooterView. You can do this in interface builder easily by dragging a view to the bottom of the tableView. Or you can do it in code (in your viewDidLoad method, for example)
Per #Justin's answer... your question isn't very clear
I'm not sure what your trying to accomplish. If your trying to access button on the bottom of a tableView why not use a Tableview Footer.
And if your trying to just scroll to the bottom of the tableview there is a method for that as well.
Need more info