我正在使用 EKEventEditViewController 将事件添加到日历中,但是我需要自定义表格 View ,例如背景颜色和单元格属性。
我尝试像这样循环遍历它的 subview ,但没有成功。
失败的代码:
EKEventEditViewController *eventVc = [[EKEventEditViewController alloc] init];
eventVc.event = event;
eventVc.delegate = self;
eventVc.eventStore = eventStore;
eventVc.editViewDelegate = self;
for (UITableView *view in [eventVc.view subviews]) {
[view setBackgroundColor:[UIColor redColor]];
}
[self presentModalViewController:eventVc animated:YES];
最佳答案
您可以使用UINavigationController
委托(delegate)方法来自定义EKEventEditViewController
。
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
if ([viewController isKindOfClass:[UITableViewController class]]) {
UITableView *tblView=((UITableViewController*)viewController).tableView;
[tblView setBackgroundColor:[UIColor redColor]];
[tblView setBackgroundView:nil];
}
}
关于iphone - 如何自定义 EKEventEditViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9264781/