uicollectionviewcell

how to access from UICollectionViewCell the indexPath of the Cell in UICollectionView

孤街浪徒 提交于 2019-11-28 18:21:37
i want to animate the UICollectionViewCell when action is called. i have done UICollectionViewCell in Interface Builder , the UICollectionView also. Now i want to get the correct indexPath at my actionBtnAddToCard method. thats the way i try it now (method in ProduktViewCell.m): - (IBAction)actionAddToCart:(id)sender { XLog(@""); // see this line NSIndexPath *indexPath = ??** how can i access the correct indexPath**??; SortimentViewController *svc = [[SortimentViewController alloc] initWithNibName:@"SortimentViewController_iPad" bundle:[NSBundle mainBundle]]; [svc.collectionViewProdukte

Is force cast really bad and should always avoid it?

◇◆丶佛笑我妖孽 提交于 2019-11-28 18:13:38
I started to use swiftLint and noticed one of the best practices for Swift is to avoid force cast. However I used it a lot when handling tableView, collectionView for cells : let cell = collectionView.dequeueReusableCellWithReuseIdentifier(cellID, forIndexPath: indexPath) as! MyOffersViewCell If this is not the best practice, what's the right way to handle this? I guess I can use if let with as?, but does that mean for else condition I will need to return an empty cell? Is that acceptable? if let cell = collectionView.dequeueReusableCellWithReuseIdentifier(cellID, forIndexPath: indexPath) as?

Where to highlight UICollectionViewCell: delegate or cell?

孤街浪徒 提交于 2019-11-28 17:50:00
According to the Collection View Programming Guide one should handle the visual state of the cell highlights in the UICollectionViewDelegate . Like this: - (void)collectionView:(PSUICollectionView *)collectionView didHighlightItemAtIndexPath:(NSIndexPath *)indexPath { MYCollectionViewCell *cell = (MYCollectionViewCell*)[collectionView cellForItemAtIndexPath:indexPath]; [cell highlight]; } - (void)collectionView:(UICollectionView *)collectionView didUnhighlightItemAtIndexPath:(NSIndexPath *)indexPath { MYCollectionViewCell *cell = (MYCollectionViewCell*)[collectionView cellForItemAtIndexPath

collectionview with the horizontal scroll with mulitple section

自作多情 提交于 2019-11-28 17:41:08
I want to develop the screen(objective C) like this : In this there are section names : New Games we Love New Apps We Love Both have horizontal scroll and independent to each other. My question is what is the possible way i should use to implement this from below two option. Please provide me any reference sample if available: Can i achieve the same behaviour withe single UICollectionView and having different section (dynamic). But the scroll for different section should be independent. Because it may possible that section 1 may have different number of items(rows) and section 2 may have

UICollectionView only calling didSelectItemAtIndexPath if user double taps, will not call when user single taps

孤者浪人 提交于 2019-11-28 16:38:44
I have a UICollectionView which is about the size of the screen. The UICollectionViewCells that it displays are the same size as the collectionView. Each cell has a UIImage which is the size of the cell. The CollectionView has paging enabled so essentially it is a full screen photo slideshow that the user can swipe through. The problem is that -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath is only being called if the user taps with two fingers on a cell or long presses with one finger and then releases. It does not seem to have the

Change UICollectionViewCell size on different device orientations

柔情痞子 提交于 2019-11-28 15:01:52
I am using an UICollectionView with UICollectionViewFlowLayout . I set the size of each cell through the collectionView:layout:sizeForItemAtIndexPath: When switching from portrait to landscape, I would like to adjust the size of each cell to completely fit the size of the CollectionView, without leaving padding space between cells. Questions: 1) How to change the size of a cell after a rotation event? 2) And, even better, how to make the layout where the cells always fit the entire size of the screen? 1) You could maintain and swap out multiple layout objects, but there's a simpler way. Just

How to add views between UICollectionViewCells in a UICollectionView?

爱⌒轻易说出口 提交于 2019-11-28 14:56:33
问题 I'm trying to add UIView s between my UICollectionViewCell s in my UICollectionView and I don't know how I could do that. I'm trying to accomplish something like this: I'll probably need to write a custom UICollectionViewLayout , but I don't really know where to start. 回答1: I studied more of how UICollectionViewLayout s work and figured out how to solve it. I have an UICollectionReusableView subclass called OrangeView that will be positioned between my views, than I wrote an

Adding rounded corner and drop shadow to UICollectionViewCell

白昼怎懂夜的黑 提交于 2019-11-28 13:49:18
问题 So I already went through various posts on adding 2nd view for adding shadow, but I still cannot get it to work if I want to add it in UICollectionViewCell . I subclassed UICollectionViewCell , and here is my code where I add various UI elements to the cell's content view and adding shadow to the layer: [self.contentView setBackgroundColor:[UIColor whiteColor]]; self.layer.masksToBounds = NO; self.layer.shadowOffset = CGSizeMake(0, 1); self.layer.shadowRadius = 1.0; self.layer.shadowColor =

UITextView font to always be fixed size

徘徊边缘 提交于 2019-11-28 12:49:16
问题 I have a UICollectionView with cells sized to the same aspect ratio as a4 page. And with different screen sizes I would like for that text to be sized at fixed 12pt (that would be calculated to that UICollectionview cell), which would look bigger on the iPad and smaller on iPhone. So having a fixed font size isn't an option... 回答1: Coding var fontSize : CGFloat = 12.0 // DEFAULT SIZE In your ViewDidLoad if UIDevice().userInterfaceIdiom == .phone { switch self.view.frame.size.height { case 480

UICollectionViewCell dynamic height with autolayout

一曲冷凌霜 提交于 2019-11-28 11:09:47
I am using auto layout with UICollectionViewCell. So the idea is to allow CollectionViewCell to determine it's size based on layouts. All the constraints are set properly but the problem is that I can not calculate it's size for data source method collectionView:layout:sizeForItemAtIndexPath: Ideally I would like to calculate Cell's height doing the following: static MyCell *myCell = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ myCell = [[MyCell alloc] initWithFrame:CGRectZero]; }); cell.model = model; [cell updateConstraints]; [cell layoutSubviews]; return cell.frame