Is there any way to change the background color/image of the details UITableView in the EKEventViewController? I'm able to change the main UITableView but not the detail UITableView due to have no outlet for the table. For example, here is Apple's example source code for a Event App
Asked
Active
Viewed 3,239 times
3 Answers
5
You shouldn't just grab the subview at index:0. This may work in your current code, but it may break in future IOS releases, if Apple makes changes to the View.
This is more "future proof"
for (UIView *searchTableView in [yourEventController.view subviews]) {
if ([eventTableView isKindOfClass:[UITableView class]]) {
@try {
// change stuff to eventTableView
for (UIView *eventTableViewCell in [eventTableView subviews]) {
if ([eventTableViewCell isKindOfClass:[UITableViewCell class]]) {
@try {
[(UITableViewCell *)eventTableViewCell setBackgroundColor:[UIColor clearColor]];
}
@catch (NSException * e) {
}
}
}
}
@catch (NSException * e) {
}
}
}
Remember all the try's and catches! If apple makes changes to EKEventViewController than the code will probably still work, and it also won't crash if the changes break backwards compatibility.

Michael Gray
- 611
- 1
- 5
- 13
3
Here is what you can use,
UITableView *eventTableView = [[yourEventController.view subviews]objectAtIndex:0];
this eventTableView
is reference to your EKEventViewController
's tableView now you can customize it.
Thanks,

Ravin
- 8,544
- 3
- 20
- 19
-
1Can you help me how can i do the same for EKEventEditViewController – Dilip Rajkumar Oct 13 '11 at 12:17
-
Don't do this. It will likely crash someday. Never write code that assumes a specific subview structure. – rmaddy Jan 19 '16 at 03:45
0
Michael Gray's answer doesn't worked for me on iOS7, for a EKEventEditViewController
maybe the EKEventEditViewController's implementation is different.
here is the code i've used:
for (UIViewController *controller in ekEventEditViewController.childViewControllers) {
if ([controller isKindOfClass:[UITableViewController class]]) {
NSLog(@"UITableViewController in EKEventViewController");
}
}

Alban
- 1,624
- 11
- 21
-
EKEventEditViewController is slightly different from EKEventViewController such that it is a UINavigationController. What you can do is by setting your EKEventEditViewController's delegate property to some controller (This delegate property is inherited from UINavigationController actually) and use the delegate method willShowViewController to get the UITableView. Then from there search for your targeted cell. The following link gives some details: http://stackoverflow.com/questions/14813240/how-to-customise-ekeventeditviewcontroller – Steve Oct 19 '15 at 01:27