I have a UIViewCollectionView. The Cells for the collection are all clickable. Each cell contains a UITableView and I also want the cells of that table view to be selectable but they arent.
I set isUserInteractionEnabled = true on the UICollectionView, UICollectionViewCell, UITableView and the UITableViewCell but I cant get the clicking working on the table view cells.
How can I do it?
In general I want all user inputs on the table view to have priority.
I have no idea why but it did not work because I used xib files instead of storyboard. I switched to storyboard and everything works fine.
Related
i need to create below design
I am following this code to draw simple collection view with horizontal scroll inside a UITableView
Current sample code work like this
UITableView-> UICollectionViewCell as cell with horizontal scroll
What i want
i want : First row with UICollectionview with horizontal scroll and
Then rest row with Normal UITableviewCell to show data
How can i do it .
add a UITableView to your view controller and implement it's delegate and datasource methods .(You can use UITableViewController instead of UIViewController).
for the fist cell of the first section in your tableview, you should use a custom tableview cell.
Inside this custom tableview cell, you have to add your collection view with horizontal scroll, and implement its delegate and data source methods inside your custom tableview cell class.
these are the steps you have to do.
refer this implement uicollectionview inside uitableview question for more.
Hope this will help to you.
You should design a UITableViewCell which has a UICollectionView inside, and set this cell for the cell in section A and for Section B, you should design a new UITableview cell.
When tableview's cellForRowAtIndexPath call you can check for First section and when first section load you can create new UICollection view object load in first cell. Than next section will load you can work as normal tableview work.
Not- you need to implement UICollectionview delegate and datasource methods also.
I am trying to add a footer to my UITableView. I was able to do this programmatically by making a new UIView with the desired height and width and setting the tableView's tableFooterView to this view.
However, I want to use a reusable tableView cell as my table footer. I tried to set the property as follows
myTable.tableFooterView = myTable.dequeueReusableCellWithIdentifier("footerCell") as UIView!
However, the table View does not show up. I was able to get it working when implementing the tableViewforSection delegate method. However, I realized that I need a table footer and not a section footer, since I'm effectively trying to create a custom last cell for my table that scroll with it.
PS: I checked the identifier for my footer cell in storyboard and it looks correct. I also tried creating a custom class for my custom cell and setting the storyboard cell to be of that type, but that doesn't work either.
If you want to use a cell for your footer, and you're using an array to populate your "regular" cells, then return the array.count + 1 in numberOfRows, and put an if clause in your cellForRowAtIndexPath to check if indexPath.row == array.count. If so, dequeue your footer cell.
In short: how can I prevent the selection of a collection view cell from affecting the selection state of table view cells that are inside that collection view cell?
I have a UICollectionView, where the cells are displayed full-screen when selected. The cells contain a UITableView that will display use information.
The problem I'm having is that the cells in the table view are being displayed as if they are selected. I moved some things around, to display a cell full-screen all the time, which allowed me to confirm: when the collection view cell is selected, the cells of the table view inside of it are also displayed with the selected style.
Note that I say they are displayed with the selected style, and not they are selected. As far as the table view is concerned, they are not selected.
[tableView indexPathsForSelectedRows]; returns no index paths. tableView:willSelectRowAtIndexPath:—from which I could return nil—is never called. So, it's safe to say that the table view doesn't perceive its own cells as being selected.
But, I can confirm in Reveal that the table view cells contain the selected background view (see the last screenshot below). This is only the case for table view cells that are visible when the collection view cell is selected: this does not happen to cells that are far enough down in the list to be off-screen initially.
I can hide the problem using cell.selectionStyle = UITableViewCellSelectionStyleNone; and ultimately, this might be my solution: the table view cells will not be selectable anyway, so painting over the problem like this should work in my situation.
But, that doesn't answer the bigger question: what the heck is going on here?
Screenshots
Normal collection view cell (this whole thing is one cell):
Selected collection view cell, with gray selected style on the table view within:
Reveal, showing the selected background view. In this case, the table cell containing the Delete button was not visible when the collection view cell was selected, so it didn't get the selection styling like the cells above it did:
I've overridden UITableViewCell's method this way
func setHighlighted(_ highlighted: Bool, animated: Bool)
{
//Leave Empty
}
Apple behaviour could be right, because in this way you could skip an iteration on all child and set manually the property, but why I can't choice if i wan't it using UICollectionViewDelegate method?
func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool
Apparently, this is the expected behavior in iOS 7. setHighlighted: is called on all subviews that support it.
For reference, this tutorial I am following: http://mobile.tutsplus.com/tutorials/iphone/customizing-uitableview-cell/
I have to create a custom UITableViewCell, and from the tutorial, it said to leverage Prototyping cells and subclass UITableViewCell. Then connect the UI elements in the prototype cel to the custom class (of UITableViewCell).
The problem I am running into here is, there is only one cell for the whole table view that is displaying data. However, I am able to click on empty cells in the background behind that one cell that contains data. If i scroll up or down, cellForRowAtIndexPath is called and another cell gets displayed. However its only displaying once cell at a time for the whole table view.
Does anyone know what the problem could be here? Any help is appreciated, thanks!
Figured out what the problem is, my labels (that are supposed to be inside the custom prototyping cell) were added to the parent view and not the content view of UITableViewCell. This is because my prototype cell did not have a content view for some reason. I had to add a another prototype cell and delete the previous one.
reference: How to add subviews to a custom UITableViewCell in a storyboard
I have just encountered a problem today that I am unable to add a new table view cell to my UITableview.
What I did was I drag a table view cell and drop inside the UITableview area. The UITableview did not take the table view cell but rather the cell become an individual view of the main view.
Clearly see that table view cell is not included in Table View
So my question is, how to create a custom table view cell in UITableview in an XIB file in Xcode 5?
Thanks in advance!
If you have dynamic prototype cell will be added automatically. If not, you can choose how much cell you want to have in inspector on right side of screen.
And make sure when you put it into screen that is inside of your tableview.
I answer this question thinking you are using storyboard. First add UITableView.
Then you can see as this,
If you want to use static cell, select Table View & in Attributes Inspector , in content select Static Cells. I think for your question you should use Static Cells.