uicollectionviewcell

Is force cast really bad and should always avoid it?

老子叫甜甜 提交于 2019-11-27 11:19:14
问题 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

How do I display the standard checkmark on a UICollectionViewCell?

风流意气都作罢 提交于 2019-11-27 11:02:58
I'm designing an iOS app with a UICollectionView, and I'd like users to be able to select multiple items within this view. It seems there's a standard style of checkmark Apple uses in this kind of situation. For example, in the image below you can see it when selecting multiple photos in a share sheet. According to the documentation , you are responsible for updating the UI of your cells to reflect their selection state. I know on a UITableViewCell you can set the accessoryType property to add a checkmark, but I can't seem to find any equivalent for a UICollectionViewCell. Is there a way Apple

Where to highlight UICollectionViewCell: delegate or cell?

自闭症网瘾萝莉.ら 提交于 2019-11-27 10:46:50
问题 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 *

Dynamic cell width of UICollectionView depending on label width

我怕爱的太早我们不能终老 提交于 2019-11-27 10:36:01
I have a UICollectionView, that loads cells from reusable cell, which contains label. An array provides content for that label. I can resize label width depending on content width easily with sizeToFit. But I cannot make cell to fit label. Here's the code - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. arrayOfStats = @[@"time:",@"2",@"items:",@"10",@"difficulty:",@"hard",@"category:",@"main"]; } - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection: (NSInteger)section{ return [arrayOfStats count

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

浪尽此生 提交于 2019-11-27 09:50:05
问题 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

Change UICollectionViewCell size on different device orientations

我们两清 提交于 2019-11-27 08:58:45
问题 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

UICollectionView update a single cell

偶尔善良 提交于 2019-11-27 07:22:30
I am attempting to update a single cell inside a UICollectionView , specifically I am just trying to update an image in that specific cell detonated by cell.imageView . [self.collectionView reloadData] is not really an option because it makes the whole collection view flash. [self.collectionView beginUpdates] is not a thing in a UICollectionView it seems. I understand I may be able to use: [self.collectionView performBatchUpdates:^{ //do something } completion:nil]; I am not exactly sure what to put inside a completion block to update that certain cell's imageView . This is all being done

UICollectionView animations (insert/delete items)

无人久伴 提交于 2019-11-27 06:45:37
I'd like to customize the animation styles when a UICollectionViewCell is inserted and/or deleted. The reason why I need this is that by default I see that inserting a cell has a smooth fade in animation, however deleting a cell has a combination of move-to-the-left + fade out animation. I would be very happy with this if not for one problem. After I delete a cell, it is still reused when I add new ones, and when it's reused it's added not with the default fade in effect, but instead it's a combination of move-to-the-left + fade in. I'm not sure why I'm getting this inconsistency in animations

Dynamic size UICollectionView cell

浪尽此生 提交于 2019-11-27 06:35:59
1) How can i achieve as shown in image with UICollectionView ? 2) I've tried -(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath method & passed different sizes but it leaves out spaces between cells. Can i empty those spaces? I want different height & width for every cell Current output: . Sorry this is super late... But maybe this will help people who haven't found an answer yet. If you have your images in an array, you can simply reference the image size and make the adjustments to

UICollectionView adding UICollectionCell

岁酱吖の 提交于 2019-11-27 06:24:19
When I try to put UICollectionCell to UICollectionView in Interface Builder I can't put it with unknown reasons. The cell is going to the tools bar without adding to UICollectionView I am using: iOS SDK 6.0 XCode 4.5.1 I don't use Storyboard Only UICollectionView inside StoryBoard have UICollectionViewCell inside. If use XIB, create a new XIB with CellName.xib, add CollectionViewCell to it, specify name of UICollectionView custom class. After that use registerNib. Sample code: https://github.com/lequysang/TestCollectionViewWithXIB You cannot put UICollectionViewCell directly into the