问题描述
我在我的应用程序中使用默认 EKEventEditViewController
,我想自定义它,目前它显示所有字段默认 EKEventEditViewController
,但我不想显示URL字段,也想添加时区字段。我可以这样做,如果是,那么请求让我知道我该怎么做呢?
您可以使用此摘录:
1)使您的viewcontroller成为您的EKEventEditViewController的委托
EKEventEditViewController * addController = [[EKEventEditViewController alloc] init];
addController.delegate = self;
2)然后在您的视图控制器上实现:
$ b $ (UIViewController *)viewController animated:(BOOL)animated {
if([viewController isKindOfClass:[UITableViewController class]]){
UITableView * tableView =((UITableViewController *)viewController).tableView;
for(NSInteger j = 0; j {
for(NSInteger i = 0; i< [tableView numberOfRowsInSection: j]; ++ i)
{
UITableViewCell * cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]];
NSLog(@cell =>%@,row =>%d,section =>%d,cell.textLabel.text,i,j);
if([cell.textLabel.text isEqualToString:@Calendar]){
[cell removeFromSuperview];
} else if(j == 5){//如果URL字段
[cell removeFromSuperview];
}
}
}
}
}
注意:我在另一个Stackoverflow回答中发现了这一点,并在我的项目上实现它。我忘了链接。希望这有助于和感谢原来的答案,我有这个。
I am using default EKEventEditViewController
in my App and I want to customize it, currently it shows all fields that came in default EKEventEditViewController
, but I don't want to show URL field and also want to add Timezone field. Can I do that and if yes then pleas let me know how can I do this?
you can use this excerpt:
1) make your viewcontroller the delegate of your EKEventEditViewController
EKEventEditViewController *addController = [[EKEventEditViewController alloc] init];
addController.delegate = self;
2) then implement this on your view controller:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
if ([viewController isKindOfClass:[UITableViewController class]]) {
UITableView *tableView = ((UITableViewController *)viewController).tableView;
for (NSInteger j = 0; j < [tableView numberOfSections]; ++j)
{
for (NSInteger i = 0; i < [tableView numberOfRowsInSection:j]; ++i)
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:j]];
NSLog(@"cell => %@, row => %d, section => %d", cell.textLabel.text, i, j);
if([cell.textLabel.text isEqualToString:@"Calendar"]) {
[cell removeFromSuperview];
} else if(j == 5) { // If URL Field
[cell removeFromSuperview];
}
}
}
}
}
Note: I found this in another Stackoverflow answer before and implemented it on my project. I forgot the link. Hope this helps and thanks to the original answer where I got this.
这篇关于如何自定义EKEventEditViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!