3

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:

Community
  • 1
  • 1
Greg
  • 34,042
  • 79
  • 253
  • 454

2 Answers2

5

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.

beryllium
  • 29,669
  • 15
  • 106
  • 125
1

I am not sure as I have never had to what you are asking, but since it subclass UIViewController try doing you color stuff on yourEventViewController.view.

Let me know if that helps.

mdominick
  • 1,319
  • 1
  • 10
  • 21
  • not quite sure what you mean here - can you give a code example? Where I'm not sure is that it's not my code launching the 2nd EDITable view, so because i'm not launching it I'm not sure where to put any code to grab a handle to the view and hence to use this to customise colors – Greg Oct 25 '11 at 02:51
  • Oh so the problem is that you can't find a way to reference the view? – mdominick Oct 30 '11 at 14:42