iPad : Problem changing the background color of Grouped TableView in iOS SDK 4.2
Asked Answered
O

3

6

I am using iOS SDK 4.2.

In my iPad app, I am not able to change the background color of Group Table View even it does not set to clear color

If I try to change the table view style from Grouped Table View to Plain Table View and then try changing the background color then it changes.

But something seems to be wrong when I am using Grouped Table View

What could be wrong?

What should I do?

Plese Help and Suggest

Thanks.

Orebro answered 20/12, 2010 at 7:19 Comment(3)
what code are you using to try change it at the moment?Magistery
@mackross: I am changing it from inspector in the XIB itselfOrebro
I have the same problem. I want to set the TableView background clear so I can display the cells over the top of my own background image. The fix below works in iOS4.2 on the simulator but not on the iPad device: #2688507Dammar
F
5

I have this problem as well. Only on iPad. Only with a grouped Table.

You can fix this by creating a new view, coloring it and then setting that new view to the backgroundView of the tableView.

This works for static colors, but not Pattern Images(what I'm trying to do)

Fictitious answered 21/12, 2010 at 5:21 Comment(2)
Yes I totally agree with you. This solved even my problem. :) ThanksDistraint
This is the correct solution if you are working with UIAppearance, which means that you do not define UItableviews background color in the viewcontroller but in a config file. setting backgroundView to nil doesnt help for this specific caseFr
E
14

Set nil to the tableview's backgroundView will solve the problem.

tableView.backgroundView = nil;

BackgroundView works only with ios 3.2 and later.
So check

if([tableView respondsToSelector:@selector(backgroundView)]) 
     tableView.backgroundView = nil; 

For backward compatibility, otherwise app will crash.

Emeldaemelen answered 21/9, 2011 at 9:12 Comment(1)
Great! my only comment: Can use self.tableView instead of tableView.Chinook
F
5

I have this problem as well. Only on iPad. Only with a grouped Table.

You can fix this by creating a new view, coloring it and then setting that new view to the backgroundView of the tableView.

This works for static colors, but not Pattern Images(what I'm trying to do)

Fictitious answered 21/12, 2010 at 5:21 Comment(2)
Yes I totally agree with you. This solved even my problem. :) ThanksDistraint
This is the correct solution if you are working with UIAppearance, which means that you do not define UItableviews background color in the viewcontroller but in a config file. setting backgroundView to nil doesnt help for this specific caseFr
W
1

There might be some problem in linking your outlet of table.
Setting the background color is not OS dependent.

You can easily set it through

[table setBackgroundColor:[UIColor blackColor]];  

Check your connections to nib file and delegate properly.

Woodsum answered 20/12, 2010 at 8:55 Comment(1)
Thanks for the input.First of all, I have connected my outlet properly. I am able to retrieve all the data into my tableview using the same outlet so I dont think that outlet is an issue. Secondly, I should be able to set the background color from the XIB, once the property is shown in the inspector. I tried all the colors but the color does not change. What should I do?Orebro

© 2022 - 2024 — McMap. All rights reserved.