Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to customize UITableView of EKEventViewController?

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

like image 565
0SX Avatar asked Apr 20 '11 03:04

0SX


2 Answers

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.

like image 53
Michael Gray Avatar answered Nov 15 '22 08:11

Michael Gray


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,

like image 40
Ravin Avatar answered Nov 15 '22 07:11

Ravin