UITableView editing-mode problems (iPhone SDK) - iphone

I have a tableView populated with custom tableViewCells. The cells are not subclasses, they are merely tableViewCells which have had a lot of tweaking and "subview-adding"(done in the cellForRowAtIndexPath method). The problem occurs when i tap the edit button. Have a look:
PICTURE_1
I know the "delete badge" is hovering above the text, I'll fix that later. My problem is that the "delete badge" and the reorderControl assumes the color of the table's backgroundColor(which I've set to be the same as the top row). I've tried doing this:
cell.accessoryView.backgroundColor = [UIColor clearColor] But it doesn't help which I assume is because the "delete badge" and reorderControl are not displayed in the accesoryView. My problem does not only count for the badge and the reorder control. It also counts for the delete button that appears when I press the delete-badge.
So do anybody know how to fix this? I'm really stuck here.
Thanks.

Looks like you need to assign a background view to your cells, and give that a background color:
cell.backgroundView = [[[UIView alloc] initWithFrame: cell.bounds] autorelease];
cell.backgroundView.backgroundColor = [UIColor gray];

Related

UITableViewCellSelectionStyleNone whilst still showing checkmark in edit mode

I am having issues setting the cell background colour on a grouped table cell when in edit mode. It seems to get the checkmark to appear a selection style has to be set and the only options are UITableViewCellSelectionStyleBlue or UITableViewCellSelectionStyleGray.
What I am after is the for the checkmark just to be selected and the cell remain white when it is checked.
You would have thought UITableViewCellSelectionStyleNone would have this behaviour but this stops the checkmark for showing.
I have tried to use setSelectedBackgroundView. This would work if the cell style was not grouped but as it is the round corners do not get drawn.
The properties for the cell above are
cell.selectionStyle = UITableViewCellSelectionStyleGray;
cell.backgroundView = [self tableViewCellRowBackground];
Where tableViewCellRowBackground is a UIView with orange background.
The editMode is the built in iOS table edit mode with the following properties set on the table
self.tblFiles.allowsSelectionDuringEditing=YES;
self.tblFiles.allowsMultipleSelectionDuringEditing = YES;
Any ideas?
cell.backgroundView = [self tableViewCellRowBackground];
This method is setting an image for your selected cell.You should check out this one to make the selection Style image nil.
In the end I had to create my own custom cells by overriding the drawrect method.

UITableViewCell contentLayer backgroundColor won't cover accessory's background

I'm writing a small application to teach myself new design and information retrieval tricks. I'm using the following line to set the background of my UITableViewCell subclass:
cell.contentView.backgroundColor = [UIColor blackColor];
... but it doesn't seem to want to get behind that accessory view:
How do I get the backgroundColor to actually span the entire background of the UITableViewCell?
The accessory view is not added to the cell's contentView. As you can see, the content view is resized by shrinking from the right so the accessory can fit in. This also happens when the delete button is shown.
You need to set the backgroundColor of the whole cell - furthermore, this has to be done in the tableView:willDisplayCell:forRowAtIndexPath:
delegate method.
If you want to set color of entire cell, then use -
cell.backgroundColor = [UIColor blackColor];
Not exactly a definitive answer to this question, but it works well when you use the "grouped" view instead of the standard UITableView style.

How to set the single background image for bothe view and tabeview

Iam developing one applciation.In that i added the one tableview to present view.I added the background image for present view.ANd whenever tableview add to view,tableview override the view and that background image not appeared.But i need to dispaly only that tablecell content on that view with that background.So please tell me how to solve this one.
Did you tried to clear the background color for UITableView.
tableviewObj.backgroundColor = [UIColor clearColor];
If this is not working, please post your sample code for our reference. Thanks.
Set the background Color for your table view to 'Clear Color' either through xib or through code.
In your viewDidLoad method write:
yourTableView.backgroundColor = [UIColor clearColor];
Tell me if it helps!

how to disable the table cell in my tableview?

i have a my requirement disable the table cell.i have controls on that cell like(textFeild,imageview,button).when i access one control it prefprms another action so plz help me . thanks in advance.
It is not clear what you want exactly. If you just want to disable the cell i think you mean this
cell.userInteractionEnabled = NO;
But what do you mean by when i access one control it performs another action ?
I would suggest using custom UITableViewCells. Put all your controls on custom cells, that way all the events pertaining to that controls would be called in the actions in your custom cell class. In the tableView class you just don't have to give any implementation for didSelectRowAtIndexPath. That way your controls on the cells would be clickable.
It could also apply a color effect:
UIView *lab = [[UIView alloc] initWithFrame:cell.frame];
[lab setBackgroundColor:[UIColor lightGrayColor]];
cell.backgroundView = lab;

Can't get label to show over background of grouped UITableView

I am trying to get a label to show over part of the grey-space in a grouped UITableView, but it only appears if the label is in a cell. I have tried adding the label as a subview of both the ViewController and the tableView and bringing it to front, but in either case it only shows over the white-space of a cell, not over the grey-space of the background. I know that I am a complete noob at Obj-C and iPhone dev and that this is a really stupid question, but I would really appreciate any help.
My code:
CGRect cgRct = CGRectMake(180, 20, 100, 50);
label = [[UILabel alloc] initWithFrame:cgRct];
label.text = #"Editting On";
label.textColor = [UIColor redColor];
label.hidden = TRUE;
//Display label
[tableView addSubview:label];
[tableView bringSubviewToFront:label];
There is probably a way to get this to work, but I'm betting that what you're trying to do is much simpler than you're making it. So, maybe explain what you want to do.
The first thing I see is you've set the hidden property to TRUE (you should be using YES, instead of TRUE by the way). If the label is hidden, you won't be able to see it, so either remove that line or change its parameter to NO.
Next, I should point out that you can add custom views for the table header and footer. You can even use custom views for section headers and footers. If what you want is a custom cell, then you'll want to either code that by hand or create a custom cell view in Interface Builder and then load it dynamically.
If what you are wanting, however, is to overlay the entire view with another view, then it will work to add the view to the top level controller's view--which is to say if you have a navigation based app, for example, you can access the navigation controller and add your view as a subview.
[[[self navigationController] view] addSubview:label];
HTH.