how to scroll the collection view in uitableview in ios9.0? - uitableview

I am facing problem only in the IOS 9.0 earlier versions i can able to scroll them easy and also i didnt get any problem like this.
this is my uitableview.I am loading many collectionview in this tableview but when i am trying to select the collectiovew cell in that time i cant able to select and also i cant able to scroll them horizontally.When i am trying to select the cell in that time the entice tableview cell is going to select.please help me how to select the collection view cell and also how to call the target method.
Please help me to resolve this problem.
I am waiting for your suggestions.
to calling the collectioncell i am using the protocol methods.
those are also not reflecting.

Sorry, but I am not sure if I understand your question.
I assume you have in every table view cell a collection view with a horizontal flow layout. If so, every table view cells would show multiple collection view cells that should be scrolled horizontally.
I would check:
Is user interaction enabled for your collection view cell? Otherwise
a tap would handled by the table view cell.
Is scrolling enabled in your collection view?
Did you set the delegate for the collection view? Otherwise no
target method would be called.

Related

Move CollectionViewCell to another section

I have a UIViewController with a collectionView inside it. The layout may seem confusing but I am making use of horizontal scrolling UICollectionViewCells, presented in 3 sections.
The main collection view is made up of 3 sections. I access 3 different UICollectionViewCell classes for each section becuase it is fetching different data for each one. Once the data is fetched, it dequeues another Cell class, which is the same one accessed for all the sections.
There are 2 buttons in each cell. When I press the button, a value changes within the database. When I re-run the program, the cell in which the button was pressed has moved to its corresponding section that it should be in as per the change. However, I want to achieve this as soon as I press the button. How can I move the cell from one section to another, baring in mind that they the cells presented are inside a collectionview cell making up the sections, which is then inside a greater UICollectionView.?
I've tried researching how to do this but no luck, and everyone seems to be using a drag and drop method which seems too complicated for what I am trying to achieve. Would appreciate any help.
Thanks
The approach I followed to achieve the above situation is using a custom Delegation when cell is removing from collectionviews. A container CollectionView has two sections with 2 different cells containing two different Horizontal UICollectionViews. These two collectionview's cells have UIButtons. When tap on one collectionView's button, that particular cell is removed, custom Delegate method calls and another CollectionView's cell is populated. This is the link of the project I have created for this particular scenario. For better understanding, here is a GIF for demonstration.

Issue with programmatically added buttons

I have a cell in the UITableView. The cell has a UITableViewCell class. In this class I programmatically add few buttons.
Note: the cell is located in the very end of the table view.
Issue:
If I'm using simulator iphone 5 > the buttons will be shown.
But if I'm using simulator iphone 6+ > the buttons will NOT be shown.
Note: when i'm opening it on iphone 5 I need to scroll to see that particular cell. on iphone 6+ i don't need to scroll there, the cell is visible right away.
So I think the issue is somewhere here. May be with the place where I do my 'buttons adding'.
Where should I call the method that sets up the buttons?
Or how can I solve this problem?
TL;DR: If you have different cell types in your table view, you should make sure they have different identifiers.
Explanation:
Table cells are re-used within the UITableView and when the table is first being displayed it won't have any re-usable cells yet. It gets the cells to display by calling on its data source through the UITableViewDataSource protocol.
The thing providing the cells will first ask the table view if it has any re-usable cells (of a particular type), before creating a new one. The way it determines the particular type is from the reuseIdentifier in the table cell.
So, if you have two different classes of table cell, but they share the same reuseIdentifier you will sometimes get one class and sometimes the other - if you get the one without buttons when you're expecting the buttons then this will be a problem!
The answer is to make sure your different cell types have a unique reuseIdentifier.

UITableView inside UITableViewCell - didSelectRowAtIndexPath

I am making an interface which have UITableView with four custom UITableViewCell's. And every other UITableViewCell have also UITableView. This mean I have TableView inside a TableView.
Let me call first tableView - ParentTableView and nested tableView - ChildTableView. So I implemented method didSelectRowAtIndexPath on both tableView's. But when the app is running, only the method of the ChildTableView is being called. I need to know inside the ParentTableView, which cell is being tapped.
How can I transfer that information further from ChildTableView to ParentTableView.
This may be a silly question, but I can not find any reliable solution so far, so please help me.
Thank You in advance, kind Sir
First, I think nested table views is a bad idea. But I don't know your use case, so it might be an exception.
The table view controller class used inside a cell have its own #protocol definition and set the outer table view as its delegate. In the inner didSelectRowAtIndexPath: it can inform the outer table view about the selected indexPath, its own indexPath and any other information you might want to transmit.
Try using collection views. You can do a layout that works like a regular table view and then in the cells that need to have a table, you can make those separate cells with another collection view inside or a table view inside of it.
As mentioned before, it's not easy doing table views inside of cells, and it can be very tricky to get things to work correctly.
This is an old tutorial I wrote which may help and be of guidance. But since then there's been collection views and auto layout, so keep in mind it's very old.

cell.accessoryType is not visible and tableView:didSelectRowAtIndexPath: doesn't works

I've a customized split view for iPad, on the left part I have the KalController (https://github.com/klazuka/Kal) the calendar component and the tableView with the events of the selected day on the Kal Date Picker.
On the other hand, I have another subview ont the right with an standard UITableView listing the next events.
When one of the rows is selected on the Kal tableView, the right TableView push the detail view of the event on the navigation Controller.
But, I don't know why, althought the rows of both UITableView has the same code, the second table view, (the right one) present two problems:
- The cells has no cell.accessoryType
- Althought the Controller has the delegate properly set, the method tableView:didSelectRowAtIndexPath: was never been raised ...
Anybody knows if there is any restriction of the number of TableViews to be displayed in the same View ... I believe should be posible ... but something doesn't works.
Of course, in The NIB the UITableView has properly set the dataSource and delegate...
Any suggestion?
Thank you,
Solved ...
the problem was the height of the rows.
In the test behaviour I had just one row, and this is the reason because it has been displayed perfectly.

How move/reorder cells from TableView1 to TableView2

I have several UITableViews, with different datasources in a iPad screen.
I need to copy/move a cell from the first tableView to the second, similar how is done with ListBox in other languages.
Now, I can reorder the cells, but the movement is restricted to the tableView. I want to drag the cell in tableView1 & drop in tableView2.
P.D. I'm open to use any other control to archive this. I take a look at AQGridView & DTGridView, however the layout is based in columns with different #items. If I can emulate columns with this controls or other then I can accept the workaround.
UPDATE:
I hope this links could help:
Observing pinch multi-touch gestures in a UITableView
This is the most close answer:
Drag and drop between two tables in ipad
I know how get a image from a view, I can detect the drag with a Gesture Recognizers, so I have all the setup in place but have not expertise in graphic development, so don't know how put this in motion...
This is definitely a very interesting question, and I wish I had the time to put together some test code to see if the idea I'm about to outline would actually work. My hope is that this will at least point you in the right direction.
UITableViewCell is a subclass of UIView, so I would create a subclass of UITableViewCell called something like DraggableTableViewCell so we can handle the touch events and then perform the following steps:
Create an instance of DraggableTableViewCell and configure it to appear like the selected cell.
Add the new cell as a subview of a view that is a common superview to both tables at the same location as the original cell.
Update the data source for the source table view and remove the original cell from the table view using deleteRowsAtIndexPaths:withRowAnimation:
Move the cell on the display by responding to touchesMoved:withEvent:
When touchesEnded:withEvent: is received, verify the cell is somewhat close to the other table view and determine the index path where to insert the new cell
Update the data source for the destination table view and call insertRowsAtIndexPaths:withRowAnimation:
Remove your draggable cell from its superview with a nice animation.
This entire process will need to be orchestrated by the view controller that controls the various table views on the screen.

Resources