iphone - 如何自定义 EKEventEditViewController?

标签 iphone objective-c ipad ekeventkit

我正在使用 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];
    }
}

看看这个 https://stackoverflow.com/a/17469491/1305001

关于iphone - 如何自定义 EKEventEditViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9264781/

相关文章:

iphone - 为本地通知选择自定义声音

iphone - 如何从另一个类访问我的 ViewController 的属性变量?

iphone - 在 TableViewController 中使用 UINavigationController 方法

iphone - 异步数据连接 iOS

ios - 每次 Xcode 重新启动时 View 错位

ios - 以编程方式将 subview 添加到 NIB 的方法

ios - iOS 中的 Paypal 定期付款

javascript - Window.open + 移动设备 + Canvas == 不工作?

ios - 在 swift 2.0 中调用另一个 UIViewController 的方法

业务分发的IOS Provisioning profile