I'm using the UIView-Glow category trying to highlight certain UITableViewCells. But it doesn't work if it's used in tableView:cellForRowAtIndexPath:.
I guess it must be used after the certain view appeared on the screen. So, is there a possibility to let certain UITableViewCells glow (even when scrolling the table view)?
Yes, there is possibility to let certain UITableViewCells glow with the category file you mentioned. You need to call the category methods in the table view delegate willDisplayCell instead of cellForRowAtIndexPath.
For example:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
[cell startGlowing];
}
Related
Is there a delegate method or something that I can implement that allows me to do something when action buttons of my tableview cell is shown and hidden again?
You can set some bool property at tableviewcell level, which could work like the trigger point to understand, whether the more option actions are visible or not.
You can also validate them with content offset of tableviewcell contentview, if offset < 0, it means the more option action buttons are visible, else are not visible.
The tableview delegate methods:
-(void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
and
-(void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath does the trick.
My custom cell contains many ui elements. I found it very difficult to reuse cells.So i set the cell created to nil in the didEndDisplayingCell delegate method of table view. Is there any issue in doing so. will it hamper performance. This is my code
(void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if ([tableView.indexPathsForVisibleRows indexOfObject:indexPath] == NSNotFound){
VBMerchantDealCell *cell = (VBMerchantDealCell *)[tableView cellForRowAtIndexPath:indexPath];
cell = nil;
}
}
Make use of the prepareToReuse method in your cell subclass. Here reset all the values to default and in the corresponding cellForRowAtIndexPath method set the appropriate values to cell.
And ya, not reusing the cell is an unnecessary performance overhead.
Yes, not reusing cells will be very bad for performance. Also using transparency in your cells is likely to affect performance (i.e. Scrolling). You can use instruments or the simulator to check for this: 'color blended layers' will color all non-opaque views as red.
I want to recognize when i select a cell and drag it over another cell.
Is there any example/ workaround for this?
My goal is to create an UITableView which allows me to merge two cells into one cell.
Thanks
You can use UITableView delegates
to move rows
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
And To compare CGRects
self.tableView rectForRowAtIndexPath:(NSIndexPath *)
Then, I believe, create, insert new cell.
I have made a custom UITableViewCell, this cell has icons, labels and text views within it. I want to make the entire cell clickable but i can't make it work.
I use the following code to handle the click
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
This only works if you touch the cell where there are no textviews, how do i make the entire cell clickable?
I have grouped static cells in a UITableView. Now I'd like to add or delete (what is easier?) one specific cell, which I've already created in my storyboard. It depends on one NSString: If my string == YES, the cell should be displayed, else it shouldn't.
already tried tableView:insertRowsAtIndexPaths:withRowAnimation:
What you need is:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
This method is part of the UITableViewDelegate protocol and will be called when the table view is about to draw a cell for a particular row. This provides a UITableViewCell for you to work with.
To identify which cell you need to hide, you can add a tag to the UITableViewCell in the storyboard. This is easier because you are adding static cells.
Then you can just do:
if ([cell tag] == someInteger) {
cell.hidden = YES;
}
You can wrap this in a condition based on the value of your string that you have mentioned.
I have added some example code on Github to illustrate this.