I have a UICollectionView in every UITableViewCell of my UITableView.
The program should perform a segue there is a click on the UITableViewCell but the cell is clickable just out of the UICollectionView.
It is clickable just in the red portions.
Do you have any ideas?
You need to disable user interaction in each collection view:
In your storyboard uncheck here:
Or in your cellForRowAtIndexPath:
cell.collectionView.userInteractionEnabled = NO;
Related
I have a tableview that has custom cells in it. The section header on the cell has a selectable textview.
When you double tap and select the textview then tap away from it... the cell literally disappears. But when I scroll completely so that the cell is out of visibility and go back then scroll back... the cell comes back.
Very confused as to why this is happening. Does anyone have any idea what would cause this issue???
Issue is specific to the Table view header section, if I have selectable textview in the other cells and tap away the cell doesn't disappear.
I think you are designed the View for header as a table view cell. The disappearing issue is may be due to two reasons
1.Please check the tableview and cell views scope you declared.If it is weak please make it as strong.
2.I will give u a sample code you need to declare in view for header delegate
If you returned cell instead of uiview it may happen.Please verify that one also.
static NSString *CellIdentifier = #"QuizCreation2HeaderTableViewCell";
QuizCreation2HeaderTableViewCell* sectionHeaderCell = (QuizCreation2HeaderTableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UIView * headerView = [[UIView alloc] initWithFrame:sectionHeaderCell.frame];
[headerView addSubview:sectionHeaderCell];
return headerView;
In my project, there is a UITableView which contains UICollectionViews in each row. Each UICollectionView contains a UIButton. I implemented those by using a tutorial here:
https://ashfurrow.com/blog/putting-a-uicollectionview-in-a-uitableviewcell-in-swift/
The problem is, I need to add an action to button click. The usual IBAction click works, but I can't pass any data except an integer (tag) to it.
The question is, how do I pass some data to my button click action?
UIButton in UICollectionViewCell
UICollectionViewCell in UICollectionView
UICollectionView in UITableViewCell
UITableViewCell in UITableView
UITableView in UIViewController/UITableViewController
so your button outlet must be on collectionviewcell class and your button's action must be in uicollectionviewcell, and you can pass data from your uicollectionviewcell to UITableViewCell with delegate (uicollectionviewcell-delegate), and UITableViewCell to UIViewController/UITableViewController with another delegate.
I am new to iOS. I need to show the Label in timeDelay in UITableViewCell only when its visible?
Create a custom UITableView cell. In your cellForRowIndexPath, call the function performSelectorWithDelay which will show your UILabel.
When the cellForRowIndexPath is called, it's pretty certain that the cell will now be shown.
I want to perform a seque from a UICollectionViewCell inside a UICollectionView. There is a UIIMage that is a subview of UICollectionView. There is a button which is a peer view of UICollectionViewCell. I have used the workarround of a transparent button on top of UIIMage to capture touch events on this cell. Now I want to perform a segue when the user clicks this Image on the collection cell. The problem is that I dont know which cell's button triggered the segue and handle it in prepare for segue.
The button triggers an IBAction where the sender is this button. How do I know which cell is its UICollectionCell underneath this transperent button ?
add tags to your buttons and perform different segues depending on the tags. Another way - without buttons would be to add tap gestures to your UIImages and perform segues depending on which image has been tapped ...
Found the solution: Its similar to the one solved for tableview (of course given UICollectionView is a repackaged table view) posted here.
The solution is to use
-(void)buttonPressed:(id)sender {
UITableViewCell *clickedCell = (UITableViewCell *)[[sender superview] superview];
NSIndexPath *clickedButtonPath = [self.tableView indexPathForCell:clickedCell];
...
}
I'm trying to get a UIScrollView to work correctly inside of a UICollectionViewCell.
The custom cell is being loaded in via a xib file and is a subclass of UICollectionViewCell. I had problems getting other controls working, such as a button and a gesture recognizer since the UICollecitonView doesn't seem to be passing any touches to the cells, but I got around those with gesture recognizers on the UICollectionView itself. The one remaining issue I have is the UIScrollViews...
The UICollectionView scrolls horizontally, and the UIScrollView in the cells scroll vertically. I've tried using a UIPanGestureRecognizer to scroll them, but that seems to disable the UICollectionView's ability to scroll.
Anybody have any thoughts?
EDIT: Got it!
So I had converted to a collection view from a previous third party library we were using before iOS6. Turns out the problem was with the xib files we were using for the cells. With the library before, the cells were just subclasses of UIViews. I changed the classes to subclass UICollectionViewCell, and updated the Custom Class. Turns out this was not enough. In order for touches to get passed to the cells I needed to actually had to drag in a new UICollectionViewCell from the Object library, copy over all the subviews and reconnect the IBOutlets. After this, it worked!
I fixed this in my code by making sure resizing of the scroll view happens on main thread.
My collection view is using nsfetchedresultscontroller that is using block calls to refresh selected cells. On the first time a cell was selected the scrollview would not scroll. However if you clicked on another cell and clicked back it would work fine. The initial load of the cell seemed like size calc might not be where it needed to be on main thread to affect behavior.
-(UICollectionViewCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:#"CustomCell" forIndexPath:indexPath];
dispatch_async(dispatch_get_main_queue(), ^{
// resizeScrollViewMethod should be where scrollview content size > scroll view frame.
[cell resizeScrollViewMethod];
});
return cell;
}
- (void) resizeScrollViewMethod {
//Do your scrollview size calculation here
}
No problem with UISCrollView in UICollectionViewCell. Use StoryBoard and you'll scroll OK.
UIScrollView overlay UICollectionViewCell, so that didSelect work only when tap outside ScrollView and inside Cell (scrollView.frame < cell.frame).
If you want to implement tap or other gesture, just add it to UIScrollView in awakeFromNib
Refer code:
https://github.com/lequysang/github_zip/blob/master/CollectionViewWithCellScrollViewStoryBoard.zip