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.

KingofBliss
  • 15,055
  • 6
  • 50
  • 72
ios
  • 6,134
  • 20
  • 71
  • 103
  • what code are you using to try change it at the moment? – mackross Dec 20 '10 at 07:56
  • @mackross: I am changing it from inspector in the XIB itself – ios Dec 20 '10 at 08:41
  • 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: http://stackoverflow.com/questions/2688007/uitableview-backgroundcolor-always-gray-on-ipad – noodl_es Jan 14 '11 at 13:25

3 Answers3

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.

Navnath Godse
  • 2,233
  • 2
  • 23
  • 32
Preetha
  • 151
  • 1
  • 2
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)

John
  • 566
  • 4
  • 3
  • Yes I totally agree with you. This solved even my problem. :) Thanks – Parth Bhatt Dec 21 '10 at 12:53
  • This is the correct solution if you are working with `UIAppearance`, which means that you do not define `UItableview`s background color in the viewcontroller but in a config file. setting `backgroundView` to nil doesnt help for this specific case – Olympiloutre Sep 24 '19 at 04:08
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.

Navnath Godse
  • 2,233
  • 2
  • 23
  • 32
Javal Nanda
  • 1,828
  • 3
  • 14
  • 26
  • 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? – ios Dec 20 '10 at 11:42