uicollectionview

UICollectionView inside UITableViewCell how to set the selection to pass data from the current view to another one

情到浓时终转凉″ 提交于 2021-02-11 06:16:12
问题 I have a view controller with a tableview inside it , in the table view i implemented a collection view with horizontal scrolling, the data appears correctly but i want to go to another view controller when i click on the collection view cell passing a string to that view , how can i handle this process . thanks in advance 回答1: You have two choice 1) Implement Collection view delegate & datasource inside view controller. You can do this in tableview's cellForRowAt method like cell

Adding UICollectionViewController to UIViewController Not Working

这一生的挚爱 提交于 2021-02-10 22:22:55
问题 I have a UIViewController and a UICollectionViewController . I add the UICollectionViewController to the UIViewController using the following: UICollectionViewFlowLayout* flowLayout = [[UICollectionViewFlowLayout alloc]init]; [flowLayout setScrollDirection:UICollectionViewScrollDirectionHorizontal]; self.toolsCollectionViewController = [[ToolsCollectionViewController alloc] initWithCollectionViewLayout:flowLayout]; self.toolsCollectionViewController.view.backgroundColor = [UIColor clearColor]

UICollectionViewDiffableDataSource: Request for number of items in section 0 when there are only 0 sections in the collection view

点点圈 提交于 2021-02-10 17:45:55
问题 I am trying to make a timeline where each section is a day and each day has many items (records). Here is my section (day) class: class YearMonthDay: Comparable, Hashable { let year: Int let month: Int let day: Int init(year: Int, month: Int, day: Int) { self.year = year self.month = month self.day = day } init(date: Date) { let comps = Calendar.current.dateComponents([.year, .month, .day], from: date) self.year = comps.year! self.month = comps.month! self.day = comps.day! } func hash(into

Dynamic width size problem in UICollectionView Cell

回眸只為那壹抹淺笑 提交于 2021-02-10 17:27:35
问题 I dynamically set width of each cell of UICollectionView according to text inside it. The problem is that most of the time the width size is correct but sometimes cell size is not correct. These are strings i displayed in cell let tabs = ["1st tab", "Second Tab Second", "Third Tab", "4th Tab", "A"] func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let text = tabs[indexPath.row] let font

How to alig cell to top by Flow Layout in CollectionView

99封情书 提交于 2021-02-09 11:51:46
问题 In this code I am trying to change the size of the first cell of the UICollectionView and the others with the same size but in the first row only one cell is coming out when I want two to come out: func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: if indexPath.row == 0 { return CGSize(width: collectionView.frame.width/1.5-2, height: collectionView.frame.width/1.5-2) } else { return CGSize(width: collectionView.frame.width/3.0-3, height: collectionView.frame

How to get position of selected item of collection view?

▼魔方 西西 提交于 2021-02-08 08:23:37
问题 In my project there is a grid of users. I made grid using collection view. When user taps on cell I need position or frame of selected cell. I have used touch event of view but it's not working in the case of collection view. override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { let touch = touches.first! let location = touch.location(in: self.view) print(location) } also this method works when you touch rest of UIView expect collectionView items. 回答1: You can use the

UICollectionView - How to set background color of a row

删除回忆录丶 提交于 2021-02-08 07:32:10
问题 I have a UICollectionView and only one section. Is there a way to set the background color of every row? (in my case it would be a gradient from black to white) 回答1: CollectionViews don't really have a concept of a rows because it's designed to have a flexible layout. Your best option is likely to have the background of the cells have your pattern and remove all the padding/margin between the cells. This will be a problem if the last row isn't full, so if the number needs to be flexible you

Subclassing UICollectionView

扶醉桌前 提交于 2021-02-08 07:21:04
问题 Does anybody know how to subclass a UICollectionView in Xamarin.iOS? I tried this public class MyCustomUICollectionView : UICollectionView { [Export ("initWithFrame:")] public InfinitiveScrollingUICollectionView (CGRect frame) : base(frame) { // initialization } } but I get The best overloaded method match for UIKit.UICollectionView.UICollection(Foundation.NSCoder) has some invalid arguments Argument #1 cannot convert CoreGraphics.CGRect expression to type Foundation.NSCoder`. I also tried to

Subclassing UICollectionView

浪子不回头ぞ 提交于 2021-02-08 07:15:13
问题 Does anybody know how to subclass a UICollectionView in Xamarin.iOS? I tried this public class MyCustomUICollectionView : UICollectionView { [Export ("initWithFrame:")] public InfinitiveScrollingUICollectionView (CGRect frame) : base(frame) { // initialization } } but I get The best overloaded method match for UIKit.UICollectionView.UICollection(Foundation.NSCoder) has some invalid arguments Argument #1 cannot convert CoreGraphics.CGRect expression to type Foundation.NSCoder`. I also tried to

Dynamic height for a UITableView based on a dynamic collection view

荒凉一梦 提交于 2021-02-08 02:01:12
问题 I have to add a UICollectionView inside a UITableViewCell . The collectionView can have a different number of items. So the collectionView should adjust properly inside the tableView . I have implemented this inside my Project: https://github.com/vishalwaka/DynamicCollectionViewInsideTableViewCell In my case, the height of the cell is not being the adjusted after the height of the collectionView is set. How can I set the collectionView to not be scrollable and also show all content inside the