uicollectionview

Collection View,with custom layouts, cells misbehave on scrolling

强颜欢笑 提交于 2019-12-31 05:12:14
问题 I am trying to create custom tiled layout using UICollectionView. It renders perfectly as desired in simulator once I run my app. But the moment I scroll the view and bring it back all the cell's frame changes and the cells get overlapped, leaving spaces, randomly. I am not able to solve this issue past 2 days. Here goes the code from my custom layout class. -(void)prepareLayout{ [self createCellSizeArray];//cellSizeArray holds cell sizes for all the cells(calculated statically) [self

HorizontalCollectionView Content width and spacing

倖福魔咒の 提交于 2019-12-31 03:57:11
问题 How can I make my horizontal collection view labels width to wrap the content width of the label and make them have equal spacing between each of them? Currently I have the collection view cell width as 100. If I increase the width to fit other labels, the shorter labels have more spacing between them. Any ideas will be appreciated. 回答1: Calculate the width of the label text first with the font associated with the text. extension String { func size(with font: UIFont) -> CGSize { let

writing events for UIswitch in collection view

試著忘記壹切 提交于 2019-12-31 03:07:10
问题 Hi I am trying to write events for UI switch and UI segmentation control in UI collection view. I declared the UIswitch and UIsegmentation control in collection view cell. @interface CollectionViewCell : UICollectionViewCell @property (strong, nonatomic) IBOutlet UISegmentedControl *mySegmentedControl; @property (strong, nonatomic) IBOutlet UISwitch *Myswitch; and access it from view controller.m - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *

Is it possible to add UIView (Admob) in uitableviewcontroller or in uicollectionviewcontroller

拈花ヽ惹草 提交于 2019-12-30 13:31:09
问题 I want to add admob in uitableviewcontroller or in uicollectionviewcontroller at the bottom of screen. So for that I have to add uiView (GAD BannerView) at the bottom of uitableview controller or uicolleectionview controller. So how can I do this? Actually we can add uiview easily in uiviewcontroller but how can I add this in uitableviewcontroller or uicollectionviewcontroller? 回答1: Yes you can also add Ad Mob in UITableView or UICollectionView . UITableViewController have a one property

UICollectionViewFlowLayout minimumInteritemSpacing doesn't work

删除回忆录丶 提交于 2019-12-30 08:38:30
问题 I've got two problems with my UICollectionView: minimumInteritemSpacing doesn't work it overflows horizontally on iOS 6 I set up the layout like this: UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.itemSize = CGSizeMake(70.0f, 70.0f); layout.scrollDirection = UICollectionViewScrollDirectionVertical; layout.minimumLineSpacing = 0.0f; layout.minimumInteritemSpacing = 0.0f; _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero

How pass data to an UICollectionView embedded in a TableViewCell (xCode - iOS - Swift 3)

馋奶兔 提交于 2019-12-30 07:34:49
问题 I implemented a CollectionView in a TableViewCell but I need read dynamic data for set cells on CollectionView. I can read data on extension from class TableViewCell, maybe can help me pass data from ViewController to the class TableViewCell. class MultipleTableViewCell: UITableViewCell { @IBOutlet fileprivate weak var collectionView: UICollectionView! } extension MultipleTableViewCell : UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView,

How pass data to an UICollectionView embedded in a TableViewCell (xCode - iOS - Swift 3)

↘锁芯ラ 提交于 2019-12-30 07:34:33
问题 I implemented a CollectionView in a TableViewCell but I need read dynamic data for set cells on CollectionView. I can read data on extension from class TableViewCell, maybe can help me pass data from ViewController to the class TableViewCell. class MultipleTableViewCell: UITableViewCell { @IBOutlet fileprivate weak var collectionView: UICollectionView! } extension MultipleTableViewCell : UICollectionViewDataSource { func collectionView(_ collectionView: UICollectionView,

UICollectionView showing wrong cells after scrolling - dequeue issue?

天涯浪子 提交于 2019-12-30 05:47:05
问题 I have a UICollectionView within a UIViewController. In the collectionView cellForItemAtIndexPath: method, it creates a series of custom cells based on the datasource. The custom cells in turn contain a UIView, subclassed to draw single PDF pages. It's set up in such a way as to split a PDF file into its single pages, so cell 1 contains PDF page 1, cell 2 contains PDF page 2 and so on. So far so good, here's my problem: When I scroll down, the UICollectionView starts displaying the wrong

UICollection View Scroll lag with SDWebImage

穿精又带淫゛_ 提交于 2019-12-30 03:24:26
问题 Background I have searched around SO and apple forum. Quite a lot of people talked about performance of collection view cell with image. Most of them said it is lag on scroll since loading the image in the main thread. By using SDWebImage , the images should be loading in separate thread. However, it is lag only in the landscape mode in the iPad simulator. Problem description In the portrait mode, the collection view load 3 cells for each row. And it has no lag or insignificant delay. In the

Programmatically create UICollectionView with custom headers

…衆ロ難τιáo~ 提交于 2019-12-30 01:44:04
问题 I'm making an iOS app in swift, and I'm trying to make a collectionView programmatically. I want to use my own subclass of UICollectionReusableView as a header for the CollectionView, because I need some buttons and a stretchable image in the header. SupView is the UICollectionReusableView. override func viewDidLoad() { super.viewDidLoad() let layout = UICollectionViewFlowLayout() layout.headerReferenceSize = CGSizeMake(self.view.frame.width, 200) someView = SupView(frame: CGRectMake(0, 0,