I am currently developing an app for iOS 5 and above in which a video is played inside a custom UITableViewCell using an instance of AVQueuePlayer.
There are ‘n’ number of such custom cells playing ‘n’ number of videos.
I want to implement a functionality which disables the player from playing the video after a given time.
I have a countdown timer which displays the time left in a UILabel for disabling the player beneath the instance of AVQueuePlayer.
I have to update the timer after a minute(suppose) to show the time left for the disabling to take place. e.g. “5 mins left”.
I am using NSTimer for this purpose. But, I dont know how to only reload or update the UILabel instance of the custom UITableViewCell. I have seen in some threads the use of the following method
- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
But, if I do so when the video is playing, it stops and gets reloaded again.
Is there a better solution to this issue?
You could either save a reference to your cell when you create it (sounds like you’re only making one of each cell type, even though you have a tableview); or grab the cell from the table and pull the label out of it.
I’d be tempted to set the tag of the label, then use that to get the label back.
When you create the label (or set it in interface-builder) call
[myLabel setTag:LABEL_TAG];Then later you can:
In the above
LABLE_CELL_POSITIONwould be position of the cell in your tableview (0 to …); andLABEL_TAGis any number you want to use to denote that view, maybe1234.