[Solved] Why does my App lags when scrolling UICollectionView (Swift)? [closed]

For the future, it is better to post the relevant code here rather than post an image of all the code. You can start off with changing the cellForItemAtIndexPath implementation. You are downloading the image in the method (as a synchronous implementation). So unless the image is downloaded by contentsOfURL: and rendered, the cell won’t … Read more

[Solved] how to use two CollectionView on same view controller scroll one by one [closed]

You can add two collection view in a single view controller by dragging it. but you have to validate UIcollection view like func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { var cell = HomeCollectionViewCell() if(collectionView == self.collName1) { cell = collName.dequeueReusableCellWithReuseIdentifier(“CellIdentifier”, forIndexPath: indexPath) as! HomeCollectionViewCell } else if(collectionView == self.collName2) {} return cell } … Read more

[Solved] How to show an image in a UICollection View cell while clicking that cell in swift ios?

Declare one instance of type IndexPath and maintain the cell status is it selected or not with it. Now use this array within cellForItemAt indexPath and didSelectItemAt indexPath like this. var selectedIndexPaths = IndexPath() func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: “Cell”, for: indexPath) as! PlaceCollectionViewCell //Your code … Read more

[Solved] Swift How can i take data from custom uicollectionviewcell?

Question: “I should take textfield value from the cell. how can I do that?” Answer: You shouldn’t do that. View objects are for displaying information to the user and for collecting input, not for storing data. This is especially important for UICollectionViews and UITableViews, since both of those create and recycle cells as needed as … Read more

[Solved] Populate CollectionView and TableView using objects at different index of same array [closed]

You can use filter method of array: //this filter will return you all objects whose group type is equal to 1 let collectionArray = (product_groups?.filter({$0.group_type == 1})) //this filter will return you all objects whose group type is equal to 2 let tableArray = (product_groups?.filter({$0.group_type == 2})) For group title to be section header: – … Read more

[Solved] My application crashes with this error – ‘NSInvalidArgumentException’

ShopCollectionObject.h #import <Foundation/Foundation.h> @interface ShopCollectionObject : NSObject @property (nonatomic) int message_id; @property (strong, nonatomic) NSString *Name; @property (nonatomic) int TimeAsPrice; @property (strong, nonatomic) NSString *Avathar;//user,Name_User,LocationOfUser,message_id @property (strong, nonatomic) NSString *user; @property (strong, nonatomic) NSString *Name_User; @property (strong, nonatomic) NSString *LocationOfUser; -(instancetype) initWithID: (int)msgID Name:(NSString *)Profile_name TimeAsPrice:(int) GivenTimeAsPrice Avathar:(NSString *) PhotoOfAvathar user:(NSString *)UserAvathar Name_User: (NSString *) … Read more

[Solved] Constrains for ImageView is not working

After researching a bit I have came up with the following way to solved this issue of AutoLayout with UICollectionViewCell. From Xcode 6 CollectionViewCell doesn’t show the contentView in interface builder, so in the awakeFromNib of cell I have set its autoresizingMask and it works like charm. class CustomCell: UICollectionViewCell { @IBOutlet var imageView: UIImageView! … Read more