Tag: uicollectionview

即使不使用自定义的XIB,在awakeFromNib中为UICollectionViewCell操作IBsockets?

下面的代码用于操作和configuration子类UICollectionViewCell的IBsockets。 然而,在这个阶段,IB级的商店还没有连接。 其他SO这样的postbuild议使用awakeFromNib来操纵IB网点,但是在所有的答案中,问题都会涉及一个自定义的XIB。 但是,这个子类不使用自定义的XIB。 即使没有使用自定义XIB,使用awakeFromNibconfigurationIBsockets是否仍然正确? override init(frame: CGRect) { super.init(frame: frame) doInit(frame) } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) doInit(frame) } private func doInit(frame: CGRect) { }

UIProgressView在UICollectionViewCell中的setFrame时不能正确工作

我在UICollectionViewCell中创build一个UIProgressView,我尝试为UIProgressView设置框架来更改UICollectionViewCell中的位置,但是当这样做时,一些单元格不显示progressView。 当我删除setFrame时,没问题,但在UICollectionViewCell顶部的默认宽度 有什么问题?如何更改UIProgressView的大小,来源? 请帮忙! //Cell:UICollectionViewCell //Cell.m – (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { //ProgressView self.progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar]; [self.progressView setFrame:progressViewFrame];//Some cells not display progressView [self.progressView addSubview:self.downloadBar]; } return self; }

被调用两次的UICollectionView numberOfItemsInSection

我有我的viewController启用分页scrollView,我想有6个集合视图,这些collectionViews是滚动视图的子视图。 collectionViews中有不同数量的项目。 viewDidLoad看起来像这样 – override func viewDidLoad() { super.viewDidLoad() //Set the frame for scroll view //Programatically created 6 collection views and added them to scrollView //Set the content size for scroll view } 每个collectionView都与viewDidLoad中的一个标签相关联。 collectionView1.tag = 0 collectionView2.tag = 1 and so on.. And the collectionViews were added to the scroll view serially starting from […]

iOS在didSelectItemAtIndexPath上展开CollectionView

所以我创build了一个应用程序,用户创build自定义的锻炼。 你input第一个视图添加轮的数量,比你点击一个button,在你添加的roundviews.That点击一个button打开另一个活动与collectionview。 所以问题是在这里,当我点击一个元素女巫代表的运动,需要在这一轮它给我一个空的结果。默认情况下,如果我添加一个值,该string的作品。 我已经注意到unwind发生在我的didSelectItemAtIndexPath之前 import UIKit class InsertWorkout: UIViewController{ @IBOutlet var InsertRoundTable: UITableView! @IBOutlet weak var txtName: UITextField! var RoundNumber : NSMutableArray = ["Round 1"] var RoundLabel : NSMutableArray = [""] var RoundExercise : NSMutableArray = ["add-1"] var RoundExerciseImages : NSMutableArray = ["providno"] var RoundNumber_Count=1 var RoundNumber_Add_Counter=1 var studentData : StudentInfo! override func viewDidLoad() { […]

横向取消UICollectionViewCells

我有一个问题,用stream布局和方向来pipe理我的UICollectionsView。 基本上,当我切换到横向时发生问题,一些UICollectionViewCells丢失。 一旦我开始滚动,它们就会重新出现。 它应该能够显示所有的单元格,因为contentSize有更多的空间。 我什至试图在我的布局: – (BOOL) shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds { return YES; } 有了同样的结果。 任何人有任何想法在这个问题上? 我包含了一个关于如何组织布局和预期行为的图像: 要添加更多的细节,每个颜色编码单元格属于它自己的部分,我正在移动我的第二部分向右方向变化使用: – (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect { NSArray* attributesToReturn = [super layoutAttributesForElementsInRect:rect]; for (UICollectionViewLayoutAttributes* attributes in attributesToReturn) { NSIndexPath* indexPath = attributes.indexPath; if (nil == attributes.representedElementKind) { attributes.frame = [self layoutAttributesForItemAtIndexPath:indexPath].frame; } else { NSString *kind = attributes.representedElementKind; attributes.frame = [self layoutAttributesForSupplementaryViewOfKind:kind […]

UICollectionView水平单元格

我试图创build一个视图集合与多个单元格。 第一个单元格必须包含一个时间线。 正如你在图片中看到的,不能横向打印时间线。 我怎样才能水平打印这个单元格? 我的代码: class ViewController: UIViewController, UICollectionViewDataSource,UICollectionViewDelegate, UICollectionViewDelegateFlowLayout { var year = 2000 override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) […]

如何在CollectionView中添加SearchBar?

试图添加一个标题SearchBar的CollectionView,但得到一个错误: 非法configuration:连接“searchBar”不能有一个原型对象作为其目的地。

Swift中Collection视图的横向方向

我在collections视图单元格中遇到了横向的问题。 当应用程序是纵向的,它给了我每行的单元格的正确数量是2.但是,当我旋转我的应用程序横向显示每行1个单元格。 这里是我得到的屏幕: 肖像: 景观: 这是我的代码添加单元格的大小: func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { var screenSize = CGFloat() if UIDevice.currentDevice().orientation.isLandscape.boolValue { screenSize = UIScreen.mainScreen().bounds.size.width } else { screenSize = UIScreen.mainScreen().bounds.size.width } let cellWidth = screenSize / 2.0 return CGSizeMake(cellWidth, cellWidth) }

当滚动浏览其中有一个CollectionView的TableView时崩溃

我有这个问题( UICollectionView里面的UITableViewCell – AutoLayout ) 并尝试了几个解决scheme,这是在互联网上可用我带着这个@Pablo Romeu的答案我试着他的解决scheme,现在我有一个TableView与其中的collectionView单元格(它可以dynamic地改变其大小的内容),但是当滚动浏览我的表查看它碰到这个错误: 2016-06-13 22:05:51.546 WishMeluck[3507:425240] the behavior of the UICollectionViewFlowLayout is not defined because: 2016-06-13 22:05:51.546 WishMeluck[3507:425240] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values. 2016-06-13 22:05:51.546 WishMeluck[3507:425240] Please check […]

应该使用什么方法dynamic更改所选UICollectionViewCell的大小?

我需要做的是扩大所选单元格的宽度,同时缩小未选中单元格的宽度,以便一次显示所有单元格。 我现在拥有的是: func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return 30 } func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { return CGSize(width: collectionView.bounds.width / 30, height: collectionView.bounds.height) } func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { var cell: UIDateSliderCell = collectionView.dequeueReusableCellWithReuseIdentifier("cell", forIndexPath: indexPath) as UIDateSliderCell return cell } […]