Nested table view in ios 6 - ios

I am creating nested table view. One table view for vertical scrolling. And another for horizontal scrolling inside the cell of first. I set the delegate of horizontal table view to vertical table view's cell subclass. But the problem is that the horizontal table view's delegate methods aren't calling.
Does any one have an idea why its not calling?

You have to make sure that you are setting the delegate programatically when configuring the cell that contains the second tableview.
Can you post some code...

Related

Two self sizing view inside one table view cell

Good evening! I want to put one table view inside cell of another table view. And inside main table view cell self sized collection view and below should be another self sized table view. But XCode want to add height constraint to collection view above or to table view below. But I need to set "wrap content" to both of them. How to do it? Please help!

How to bring a Table View Cell's content view above all other Table View subviews?

Scenario -
I have a table view on which I have added custom views by tableView.addSubView(myView).
Now I have a certain cell whose contentView needs to be shown above tableView.
Methods Tried
I tried passing a tag on the cell's contentView and iterating on all table view's subView's. But that didn't help out.
How to move a cell's contentView above any other sub views of table view?

Scrolling issue in nested UITableview in iOS

I'm creating a layout where the data should scroll vertically and each rows data should scroll vertically. To accomplish this I have used UITableView as parent and inside each UITableViewCell, I am adding UITablview for vertical scroll.
The parent UITableView has only two section, each section has child UITableView. The Child tableView has more than 50 rows. I am facing scrolling issue.
I want that the child UITableView scrolls only when the respective section reaches to top of the screen. Now the behaviour is it scrolls independentaly.
How we can achieve this?
You have to make a custom subclass of your inner UITableView and override following method based on your condition and return true/false:
touchesShouldBegin(_:with:in:)
Try by setting following property to the main table view.
self.tableView!.delaysContentTouches = true
self.tableView!.canCancelContentTouches = true
Another option is, Use TableView inside CollectionView

UITableView inside UICollectionView handling touches.

Collection view consists of a single row, of horizontally aligned cells, which size is the same size as the collection view's bounds, single cell fills entire screen.
The problem is that the collection view seems to be intercepting all of the pans. How can I forward them to the table so I can also scroll the table vertically.
I want vertical pan to be delivered to the table inside the cell, so it can scroll up and down. I want horizontal pan to be delivered to the collection view, so it can scroll horizontally.
Any ideas? Thanks.
For UITableView inside CollectionView using storyBoard, please follow these steps:
-Drag CollectionView to UIViewController, drag datasource to UIViewController(don't drag delegate). Add datasource methods inside ViewController.m
-Create Cell:CollectionViewCell class. choose class for Cell in storyBoard to Cell class,specify reuse ID.
-Drag tableView inside collectionCell square. delegate, datasource drag to CollecionCell Square too. Add tableView datasource, delegate inside Cell.m
-Create CellDelegate when implement tableViewDidSelect inside it. Transfer this delegate to UIViewController to perform other action
Sample code: https://github.com/lequysang/github_zip/blob/master/TableViewInCollection.zip
Swift2 update - We don't need to do all the above steps. Just making the controller the delegate and datasource of both the tableview and collection view works just fine.
I've been able to make this work without using storyboards--although, I use XIBs for my views but only to add the Autolayout rules. All customisation (colors, fonts, labels, etc.) are set in code. In any case, this should also work for cells that are being built programatically.
How to do it:
The most important thing to remember is to add your custom view to the contentView property of the cell and not inside the cell itself. If you are using XIBs for the custom UICollectionViewCell, leave it blank. Instantiate your custom view (where the UITableView is), then add it as a subview of the UICollectionViewCell's contentView. If you add the table vie directly inside the collection view cell, the table view will not vertically scroll.
Implement shouldSelectItemAtIndexPath and shouldHighlightItemAtIndexPath of the UICollectionViewDelegate and make both return false, so that tapping on the collection view cell does not intercept with taps intended for the table view inside.
Done with Xcode 7.3 for iOS 9+.

Issue with row selection UITableView inside UIScrollView

I have a view controller with following layout:
Container View
UIScrollView
UITableView as a sub view of a UIScrollView
I have another UITableViewController in which I have a few rows and some methods when the row gets selected. Now I want to display this UITableview inside the UIScrollView. So I add the UITableView as a subview of UIScrollView. The table is displayed in the scroll view just fine, but when I tap in the scroll view to select the table's row, then row is being highlighted but the method is not getting called when the row is selected..
PBDashboardPickupTable *dashtable = [[PBDashboardPickupTable alloc]initWithNibName:#"PBDashboardPickupTable" bundle:nil];
[self.scrollView addSubview:dashtable.tableView];
Also I have set scroll view's delayContentTouches to YES and cancelContentTouch to NO from Interface Builder. Also userInteractionEnabled is set to YES... then why is the method not getting called when I tap the table view's row?
Apple specifically warns in the documentation to avoid putting a UITableView inside of a UIScrollView:
Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.
Since UITableView inherits from UIScrollView, I would suggest you add any additional views you need as a tableHeaderView, tableFooterView, or as custom cells in the table.

Resources