|
|||||||
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
A single instance of a UIView subclass across the cells of UICollectionView
Hi,
I want to use a single instance of a subclass of UIView (so that it doesn't have to be redrawn) as the background of the cells of my UICollectionView. The way I have set it up is, in the UICollectionView, declare a variable (nonatomic, strong) of the class for my background view. In viewDidLoad, I initialize the view with the frame (0, 0, width, height). In my subclass of UICollectionViewCell, I have a variable declared for the background (nonatomic, weak). Then back in my CollectionView, in the cellForIndexPath method, I assign the initialized background view to the cell's background view and call "setNeedsDisplay" to force a redraw. This works, but only for the first cell, not any other. Is my approach correct? |
|
|
|
0
|
|
|
#2 | |
|
Quote:
You're going to have to create multiple instances of your view. Alternately, you could capture a snapshot of your view to a UIImage, and install that image as the contents of multiple image views. UIImage objects CAN belong to more than one view at a time.
__________________
Regards, Duncan Champney, WareTo. Check out our latest app, Face Dancer, available for free on the App Store. |
||
|
|
0
|
|
|
#3 |
|
|
0
|
|
|
#4 |
|
It doesn't make much difference. Views cache their contents by default, and only get redrawn if something changes. Don't call setNeedsDisplay on the view unless something changed where the view needs to be redrawn but the system doesn't do it automatically.
__________________
Regards, Duncan Champney, WareTo. Check out our latest app, Face Dancer, available for free on the App Store. |
|
|
|
0
|
![]() |
|
| Tags |
| instance, single, uicollectionview |
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 07:18 PM.









Linear Mode
