uicollectionviewcell

iOS: Image view aspect fit with corner radius

此生再无相见时 提交于 2019-12-10 11:30:00
问题 I want to set corner radius with content mode as aspect fit using following code: cell.imgvAlbum.contentMode = UIViewContentModeScaleAspectFit; cell.imgvAlbum.clipsToBounds = YES; cell.imgvAlbum.layer.cornerRadius = 5.0f; but i am getting output only for content mode as aspect fit. I have also tried for: cell.imgvAlbum.layer.masksToBounds = YES; What to do for corner radius? Please suggest me some solution. Thanks in advance. 回答1: Use below method to get a Rounded corner image with the

How do I get a UIButton press to work in a UICollectionViewCell in Swift?

亡梦爱人 提交于 2019-12-10 11:07:41
问题 So this is a tvOS project in Swift. I have a custom UICollectionViewCell with a button as one of its subviews. I add a target to the button to allow it to interpret clicks. Here's a simplified version of the relevant code class CustomCell: UICollectionViewCell { var button:UIButton! override init(frame: CGRect) { super.init(frame: frame) button = UIButton(...) // Button is initialized with a frame button.userInteractionEnabled = true button.enabled = true button.addTarget(self, action:

Custom Triangular UICollectionviewCell In collectionview

混江龙づ霸主 提交于 2019-12-10 10:33:58
问题 Normally UICollectionviewcell is of rectangular box shaped and we can modify the appearance in custom UICollectionViewCell , But in my case i want the cell to be of shape triangular or any shape other than simple rectangular, How can i achieve this function? 回答1: override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath:

UICollectionVIew inside a UITableViewCell how to get dynamic height with autolayout

纵然是瞬间 提交于 2019-12-10 09:05:55
问题 I know that there is a similar question, but I'd like to give more hints about how I tried to achieve that since the original question doesn't give any advice. I have a UITableViewCell as a subview of the contentView there is a UICollectionView , I'd like to have the cell height in function of the collectionview contentSize , the table view cell is the collection view delegate and datasource. The collection view should be fixed without scrolling possibilities in a vertical flow and it should

How to compare a color in swift

守給你的承諾、 提交于 2019-12-10 04:19:08
问题 I am trying to compare colors but I cannot use the isEqual method because I am trying to compare the color of the background of a UICollectionViewCell . What is the correct way to compare colors in this situation? if(cell!.layer.backgroundColor! == UIColor.redColor().CGColor) { cell?.layer.backgroundColor = UIColor.redColor().CGColor } 回答1: Try CGColorEqualToColor(_ color1: CGColor!, _ color2: CGColor!) -> Bool . 回答2: I've come up with this in a playground, I've assigned the backgroundColor

Set up a UICollectionView delete button in Swift

浪子不回头ぞ 提交于 2019-12-10 00:20:00
问题 I am building an app that uses a collection view to display data that can be deleted by users. In the prototype cell, I created a button that now appears in every cell that is created (a small X). How can I set the button up to tell me which cell should be deleted (like indexPath.row)? In principle, I want to do something like this, but in Swift: link I'd be grateful for any help! Thanks 回答1: - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:

UICollectionView didSelectItemAtIndexPath not called when tapped on UITextView

限于喜欢 提交于 2019-12-09 14:40:34
问题 I have a UICollectionView with custom cells- They have a UITextView that mostly covers the entire cell. This presents a problem when using didSelectItemAtIndexPath . The only way to trigger it is by tapping outside the UITextView . I want it to trigger wherever in the cell you tap, whether there is a text view or not. How can this be done? 回答1: I would suggest to use UIGestureRecognizer for each cell and when it taped to send it to UITextView or whatever , perhaps there maybe a better

Simple UICollectionView to show images behaves odd: Some Images are displayed correct, some at wrong position, some missing at all

ぐ巨炮叔叔 提交于 2019-12-09 07:59:22
问题 I want to show images in a grid on iPhone using a UICollectionView, showing 3 images a row. For a "dead simple test" (as I thought), I've added 15 JPG images to my project, so that they'll be in my bundle and I can load them simply via [UIImage imageNamed:...]. I think I've done everything correct (setting up & registering UICollectionViewCell subclass, use of UICollectionViewDataSource Protocol methods), however, the UICollectionView behaves very weird: It shows only a few of the images in

Asynchronous downloading in UICollectionView error with AFNetworking

坚强是说给别人听的谎言 提交于 2019-12-09 04:37:30
Hi I'm creating Uicollection view with list ofcatalogs, While tapping on cell the PDF have to download, Its working in one view perfectly but in another view gives the error * thread #1: tid = 0x4b2ce, 0x000000018d14f9b8 CoreFoundation`CFURLCopyScheme + 56, queue = 'com.apple.NSURLSession-work', stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x000000018d14f9b8 CoreFoundation`CFURLCopyScheme + 56 frame #1: 0x000000018cdab96c CFNetwork`_urlIsHTTPish + 16 frame #2: 0x000000018cdc76b0 CFNetwork`URLRequest::addOverridingSessionAttributes(_CFURLSessionConfiguration*) + 288 frame #3:

Display just two columns, with multiple rows in a CollectionView using storyboard

醉酒当歌 提交于 2019-12-09 04:08:33
问题 I want to display only two cells in a row, no matter what the iPhone screen size is. Like, My storyboard contains a UICollectionView ,connected by constraints. The storyboard settings for the UICollectionView is, Now, when I run this in 6, 5s or below, only one cell appears in a row. The code I'd used is, - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return [categoryImages count]; } - (UICollectionViewCell *)collectionView: