ABTableViewCell selected lag - uitableview

I've successfuly subclassed ABTableViewCell for fast scrolling.
I really recommend it to anyone who's making an app with big tableViews...
http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/
My problem with it is that when I tap a row, there is a small delay until it gets selected. I tried to put [cell setSelected:true] in the didSelectRowAtIndexPath method of the tableView, and it still lags. Has anyone experienced this as well with a ABTableViewCell subclass?
I didn't have this issue using regular UITableViewCells.

A cell can be highlighted (on touchDown) or selected (on touchUp).
Code that came with ABTableViewCell:
if(self.selected) {
backgroundColor = [UIColor clearColor];
greyColor = [UIColor whiteColor];
blackColor = [UIColor whiteColor];
}
Had to replace it with:
if(self.highlighted || self.selected) {
backgroundColor = [UIColor clearColor];
greyColor = [UIColor whiteColor];
blackColor = [UIColor whiteColor];
}
And that killed the cell selection lag.

Related

background for uitableview cell

MyTableCell *cell=[[MyTableCell alloc]init];
cell.backgroundColor = [UIColor clearColor];
The above lines of code are still showing the white color of the cell's background and hiding the background image of the tableview.
Go to you storyboard and set the color of your uitableview cell to clear color from there.And also set uitabelview color also to clear color.
Or in you viewdidload set tableview background color to clear color and in cellforrow at indexparth delagate set
cell.contentView.backGroundColor = [UIColor ClearColor]
try this
- (void)tableView:(UITableView *)tableView willDisplayCell(UITableViewCell *)cellforRowAtIndexPath:(NSIndexPath *)indexPath
{
[cell setBackgroundColor:[UIColor clearColor]];
}
set the contentview background color also
cell.contentView.backGroundColor = [UIColor ClearColor];
cell.backGroundView.backGroundColor = [UIColor ClearColor];
cell.selectedBackGroundView.backGroundColor = [UIColor ClearColor];
Also check if you cleared the tableView.backGroundColor also
Thank you every one. I have solved the problem. I changed the background attribute in the attribute inspector in the storyboard for my cell object from default to clear color and it worked.
You can do it this way
cell.backgroundColor = [UIColor clearColor];
cell.backgroundView.backgroundColor = [UIColor clearColor];

ios Change background of static TableView

I'm trying to put a background image into a UITableViewController with static cells inside.
Usually, in normal UIViewControllers I do this by changing the UIViewController's background color and setting the tableview's background color to clearcolor and opaque to NO
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"defaultBackground.png"]];
self.tableView.opaque = NO;
self.tableView.backgroundColor = [UIColor clearColor];
but doing this in my UITableViewController with static cell's leaves me with a transparent tableview with a black background. It seems like there is no view underneath.
I tried to add the view and make it contain the tableview, but this leaded to an empty view without the tableview.
self.view = [UIView alloc]initWithFrame:self.tableview.frame;
[self.view addSubview:self.tableView];
[self.view bringSubviewToFront:self.tableView];
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"defaultBackground.png"]];
self.tableView.opaque = NO;
self.tableView.backgroundColor = [UIColor clearColor];
Is there a way to fix this?

cannot set background color of UITableViewCell in iOS6?

I started testing my app under simulator, because I don't have any iOS 6 device and stumbled upon weird problem. I cannot set backgroundColor property of UITableViewCell. If I st this:
cell.contentView.backgroundColor = [UIColor redColor];
it is working only for iOS 6, when I use this:
cell.backgroundColor = [UIColor redColor];
or this
[cell setBackgroundColor:[UIColor redColor]];
it is working only for iOS7.
When I use both cell.contentView and cell.backgroundColor it's working for both iOS... shouldn't it be one answer for such a 'easy' property? Or maybe it's some simulator bug?
UPDATE:
If it changes anything in the same tableview and cells I cannot set accessoryType neither via StoryBoard nor code...
UPDATE2: for some reason setting tableview style to plain deleted all my changes, but grouped showed as expected...
In iOS6 you need to change the cell's backgroundColor in willDisplayCell.
This works in iOS7 as well, precluding the need for version-specific code.
- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
[cell setBackgroundColor:[UIColor redColor]];
}
I don't see the problem in setting the background for the contentView AND directly to the cell. iOS 7 has change a lot this class. If you need to be compatible with old systems then you need to do this type of things.
So yes, you should use both:
cell.contentView.backgroundColor
cell.backgroundColor
Try to change the cell's backgroundView color not the backgroundColor.
UIView *myView = [[UIView alloc] init];
myView.backgroundColor = [UIColor whiteColor];
cell.backgroundView = myView;
If you set (assuming you use standard cell):
cell.textLabel.backgroundColor = [UIColor clearColor];
...then you just have to use:
cell.contentView.backgroundColor = [UIColor redColor];
iOS 6 seems to copy table's background color to textLabel.
try to add this code:
cell.backgroundView.backgroundColor = [UIColor clearColor];

Setting UITableView backgroundColor in universal app (iOS 5)

I have to set the backgroundColor property of a UITableView to a certain color in my universal app. If I write this...
self.tableView.backgroundColor = [UIColor colorWithRed:146.0f green:197.0f blue:240.0f alpha:1.0f];
...it doesn't work on iPhone nor iPad (background results white).
If I use a standard color, instead...
self.tableView.backgroundColor = [UIColor greenColor];
...it works on iPhone but not on iPad.
I tried other solutions suggested on SO (backgroundView to nil/clearColor, etc.), but none of those works on iOS SDK 5. Can you help me?
You need to divide each color value to 255.
Your color will be:
[UIColor colorWithRed:146/255.0 green:197/255.0 blue:240/255.0 alpha:1.0];
Instead of changing the background color, you can set a backgroundView (with the background color that you like) for the tableView.
UIView *bgView = [[UIView alloc] initWithFrame:self.tableView.bounds];
bgView.backgroundColor = [UIColor redColor];
self.tableView.backgroundView = bgView;
Are you using a navigation controller?
Try this:
self.tableView.backgroundColor = [UIColor clearColor];
[self.tableView setSeparatorColor:[UIColor clearColor]];
self.navigationController.view.backgroundColor = [UIColor greenColor];
Thats what I use with iOS5 and an universal app.

Changing the background color of a UILabel within a UITableViewCell

A UITableViewCell comes "pre-built" with a UILabel as its one and only subview after you've init'ed it. I'd really like to change the background color of said label, but no matter what I do the color does not change. The code in question:
UILabel* label = (UILabel*)[cell.contentView.subviews objectAtIndex:0];
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor darkGrayColor];
label.opaque = YES;
Your code snippet works fine for me, but it must be done after the cell has been added to the table and shown, I believe. If called from the initWithFrame:reuseIdentifier:, you'll get an exception, as the UILabel subview has not yet been created.
Probably the best solution is to add your own UILabel, configured to your standards, rather than relying on this (very rickety) path to the built-in one.
This doesn't work because the UITableViewCell sets its label backgroundColors in the layoutSubviews method.
If you want to change the color of the built-in textLabel or detailTextLabel, subclass the UITableViewCell and override layoutSubviews. Call the super implementation, THEN change the backgroundColor property to what you want.
- (void) layoutSubviews
{
[super layoutSubviews];
self.textLabel.backgroundColor = [UIColor redColor];
}
Add your own label to the contentView when you are allocating the cell, rather than relying on the extraction of the built in one. Then you can control all values:
UILabel* label = [[[UILabel alloc] init] autorelease];
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor darkGrayColor];
label.opaque = YES;
[cell.contentView addSubview:label];
for (UIView *views in views.subviews)
{
UILabel* temp = (UILabel*)[views.subviews objectAtIndex:0];
temp.textColor = [UIColor whiteColor];
temp.shadowColor = [UIColor blackColor];
temp.shadowOffset = CGSizeMake(0.0f, -1.0f);
}

Resources