iOS: is it possible to make table view header section width bigger than tableview width itself? - ios

Is there a way for a table view header section to have a bigger width then the actual table? Here's a simple picture that shows what I mean:
Basically, I need to make the header section to extend beyond the small table view.
Is it even possible?
Thanks!

What worked for me is subclassing UITableCell and overriding setFrame method.

Related

One section of the view controller is still and one section horizontally scrollable

I would like to construct a view controller where one section of the view controller would be still and one section scrollable.
Both sections have headers where as well, one is still and one is moving along with the content in the section.
I do not want the cells in the section to be scrolled separately. All cells should move at the same time along with the header.
I have added an image to make my point little more clearer.
Use UICollection View for both view and disable scrolling for one view and enable scrolling for another view
you can probably add to your UIViewController view a UITableView on the left with fixed size (for example 150px) and vertical scroll disabled and a UICollectionView with horizontal flow and ,if needed a, with custom UICollectionViewLayout (but i think that you just need the classic UICollectionViewFlowLayout) for the right part that fits the remaining space.
Here you can find the component's documentation:
https://developer.apple.com/reference/uikit/uicollectionview
https://developer.apple.com/reference/uikit/uitableview

Resize UITable Header View Auto Layout

I am building a simple iOS application using Swift.
One of my views, displays a list of comments (cells in a PFQueryTableViewController...I am using Parse.com for my database).
My cells resize happily in order to fit the possible multiple-lines of the comments. This is MAGIC! (if you ask me)
What I am having trouble doing, is making the UIView which is at the top of the TableView resize based on multiple lines worth of content for the Label in that top view (see below).
Instead of doing multiline and resizing the view (I have set up constraints and set lines of text to 0), the label only shows one line, truncating it at the edge of the screen with "..."
Does anyone have any suggestions or solution for how to cause my top UIView to resize based on the content of the UILabel?
I was also thinking this could maybe better be done using a Container View at the top of the TableViewController?
There is a delegate method in UITableViewDelegate that lets you return the height of the head view (heightForHeaderInSection). You have to implement it making sure you return the proper height.
If you have a nib with constraints already, you can load the nib in a #property, and use the method systemLayoutSizeFittingSize that should give you enough height.
For more details checkout this post I wrote a while ago: Customize the UITableview with different height of cells like Facebook feeds in iOS

How to add UIScroller in UITableViewCell?

I have a table with different cells and I need to add a scroller view with special UI in some cells:
I need to develop the UI which you can see in section 0.
So my questions are:
How can I add a scroller view?
How can I load data only for those items which are shown right now?
How can I change the width of "Line" column after scrolling to the right?
I'll answer as best I can with some starting pointers for you...
You need to subclass UITableViewCell and in your subclasses drawRect method you should add a UIScrollView to the contentView.
Not totally sure what you mean here, please expand.
In your new table cell, set it as the delegate of the scroll view you implemented, then you''ll get callbacks when the scrollview scroll with the contentOffset value, which you can use to calculate how much to grow or shrink the line items.

TableView height change in Swift

I'm trying to find a way of making the height of a UITableView change depending on how many rows are in the table being displayed.
I've gone through the site for previous questions but none really come to any conclusion.
Language being used is Swift on iOS 8.
Thanks,
Anthony
Use tableFooterView to pin content to the bottom of a UITableView
EDIT:
The tableFooterView (and tableHederView) can be modified directly in Interface Builder by dragging a view below (or above) the prototype cell(s) in your table view.
I wanted to do this within the IB. The way around it was to drag a new view underneath the prototype cell that was already showing in the IB. Then I could change the size to suit my footer content and then just add the footer parts of the layout to that new view within the Table View.

Is it possible to merge the cells in a UITableView so that i can add some image at the right side?

As seen in the image of my design that i have attached, i want to merge(don't know wether thats the correct word) the first three cells so that i can display an image at the right side in the table itself. Is it possible?
No it's not possible. Instead, you can create first three as one cell(type1), other cells are other type(type2).
Update: see this tutorial for how to create custom cell.
You can create a UIView with fixed dimensions(say, 200x200) having 3 textfields (number, name & uom) to left and add UIImageView to right. Create IBOutlet of this view and name it. Add this view to the header of your UITableview.
self._table.tableHeaderView = yourview;
You should use a UICollectionView instead and apply a custom layout to achieve this.
Collection views provide the same general function as table views
except that a collection view is able to support more than just
single-column layouts. Collection views support customizable layouts
that can be used to implement multi-column grids, tiled layouts,
circular layouts, and many more. You can even change the layout of a
collection view dynamically if you want.
There are many tutorials on the Internet:
http://skeuo.com/uicollectionview-custom-layout-tutorial
http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12
Another option is to use UITableView and a custom UITableViewCell.
Example:
http://www.idev101.com/code/User_Interface/UITableView/customizing.html
add it in the first cell.The size of you imageview shoud be greater than the cell height.Make sure cell.cliptobounds is set false.Make sure you set the zpositon of imageview to 1 by imageView.layer.zPosiziton = 1.
Actually, you can add your imageView as subview of tableView, so your didSelectRowAtIndexPath: will working as usual

Resources