Search code examples
iphoneiosekeventekeventkit

how to customise color of EKEventEditView displayed by EKEventView?


BACKGROUND:

QUESTION:

  • My question is how do I customise the color of EKEventEditView, for which the view wasn't trigged by my code, but rather by the apple code in the EKEventView.

LINKS TO API:


Solution

  • I don't know how Apple will respond to this code, but it works :)

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(willShowController:) 
                                                 name:@"UINavigationControllerWillShowViewControllerNotification" 
                                               object:nil];
    

    And selector method:

    -(void)willShowController:(NSNotification*)sender{
        NSLog(@"%@ ", [sender description]);
    
        UIViewController *controller = (UIViewController*)[sender object];
    
        if ([controller isKindOfClass:EKEventEditViewController.class]){
            UITableViewController *rootController = (UITableViewController*)[(UINavigationController*)controller visibleViewController];
    
            UITableView *tv = (UITableView*)[rootController view];
            [tv setBackgroundColor:[UIColor redColor]];
            UIView *v = (UIView*)[[tv visibleCells] objectAtIndex:0];
            v.backgroundColor = [UIColor blueColor];
        }
    }
    

    There is only one string UINavigationControllerWillShowViewControllerNotification which you cannot find in SDK. But in this case it's only the string.. Hope this help you.