背景:
我现在可以了解如何自定义 EKEventView 的颜色,EKEventView 是一个可用于显示日历事件的苹果 View 。代码是我在这里的帖子:is this code future proof for customising color of EKEventViews (code attached)
如果此 View 是可编辑的,但是 apple EKEventView 类将显示模态“EKEventEditView” View 。
问题:
- 我的问题是如何自定义 EKEventEditView 的颜色,为此 View 不是由我的代码触发的,而是由 EKEventView 中的苹果代码触发的。
API 链接:
EKEventViewController:http://developer.apple.com/library/ios/#documentation/EventKitUI/Reference/EKEventViewControllerClassRef/Reference/Reference.html
EKEventEditViewController - http://developer.apple.com/library/ios/#documentation/EventKitUI/Reference/EKEventEditViewControllerClassRef/Reference/Reference.html
最佳答案
我不知道 Apple 将如何回应这段代码,但它确实有效:)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(willShowController:)
name:@"UINavigationControllerWillShowViewControllerNotification"
object:nil];
和选择器方法:
-(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];
}
}
只有一个字符串 UINavigationControllerWillShowViewControllerNotification
SDK 中找不到。但在这种情况下,它只是字符串..
希望对您有所帮助。
关于iphone - 如何自定义EKEventView显示的EKEventEditView的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7883945/