为 EKEventEditViewController 设置背景颜色/图像
以下是我添加日历事件的代码。我想发送 EKEventEditViewController 的背景图像。我找到了这段代码
UITableView *eventTableView = [[editController.view subviews]objectAtIndex:0];
使用此代码我能够为 EKEventViewController 设置背景图像,但它不适用于 EKEventEditViewController。非常感谢任何帮助。提前致谢。
EKEventEditViewController *editController = [[EKEventEditViewController alloc] init];
// UITableView *eventTableView = [[editController.view subviews]objectAtIndex:0];
// [eventTableView setHidden:YES];
// [eventTableView setBackgroundColor:[UIColor redColor]];
NSMutableArray *allViewControllers = [NSMutableArray arrayWithArray: editController.viewControllers];
NSLog(@"%i", [allViewControllers count]);
UITableView *eventTableView = [[[allViewControllers objectAtIndex:0] subviews] objectAtIndex:0];
// UITableView *eventTableView = [[editController.view subviews]objectAtIndex:0];
// eventTableView.backgroundColor = [UIColor redColor];
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"honeycomb.png"]];
eventTableView.backgroundColor = background;
// [background release];
editController.event = [eventsList objectAtIndex:indexPath.row];
editController.eventStore = self.eventStore;
editController.editViewDelegate = self;
itsSelectedReminder = indexPath.row;
isReminderDeleted = TRUE;
[editController.navigationBar setTintColor:[UIColor colorWithRed:67/255.0 green:114/255.0 blue:18/255.0 alpha:1]];
[self presentModalViewController:editController animated:YES];
[editController release];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
The following is my code for adding a calendar event. I want to sent a background image for EKEventEditViewController. I found this code
UITableView *eventTableView = [[editController.view subviews]objectAtIndex:0];
Using this code I was able to set background image for EKEventViewController but its not working for EKEventEditViewController. Any help is greatly appreciated. Thanks in advance.
EKEventEditViewController *editController = [[EKEventEditViewController alloc] init];
// UITableView *eventTableView = [[editController.view subviews]objectAtIndex:0];
// [eventTableView setHidden:YES];
// [eventTableView setBackgroundColor:[UIColor redColor]];
NSMutableArray *allViewControllers = [NSMutableArray arrayWithArray: editController.viewControllers];
NSLog(@"%i", [allViewControllers count]);
UITableView *eventTableView = [[[allViewControllers objectAtIndex:0] subviews] objectAtIndex:0];
// UITableView *eventTableView = [[editController.view subviews]objectAtIndex:0];
// eventTableView.backgroundColor = [UIColor redColor];
UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"honeycomb.png"]];
eventTableView.backgroundColor = background;
// [background release];
editController.event = [eventsList objectAtIndex:indexPath.row];
editController.eventStore = self.eventStore;
editController.editViewDelegate = self;
itsSelectedReminder = indexPath.row;
isReminderDeleted = TRUE;
[editController.navigationBar setTintColor:[UIColor colorWithRed:67/255.0 green:114/255.0 blue:18/255.0 alpha:1]];
[self presentModalViewController:editController animated:YES];
[editController release];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这件事让我抓狂了一段时间,但我终于明白了。
诀窍是以某种方式访问 EKEventEditViewController 内的表视图,并且似乎只有一种(已记录的)方法可以做到这一点:
首先,设置呈现 EKEventEditViewController 的视图控制器(或任何您想要的)想要负责自定义)作为
UINavigationControllerDelegate
:其次,将视图控制器设置为
EKEventEditViewController
的委托:第三,在delegate:
此示例会将
EKEventEditViewController
的表视图背景更改为蓝色,但现在您可以访问实际的导航控制器和内部的表视图,您可以做任何您想做的事情!注意:我尚未向 Apple 提交此代码,但我没有使用任何未记录的内容,因此我不知道什么会导致问题。
享受!
This one drove me nuts for a while, but I finally figured it out.
The trick is to somehow get access to the table view inside the EKEventEditViewController, and there seems to be only one (documented) way to do that:
First, set the view controller presenting the
EKEventEditViewController
(or whatever you want to be responsible for the customization) as aUINavigationControllerDelegate
:Second, set your view controller to be the
EKEventEditViewController
's delegate:Third, implement the following method in the delegate:
This example will change the
EKEventEditViewController
's table view background to blue, but now that you have access to the actual navigation controller and the table view inside you can do whatever you want!Note: I have not yet submitted this code to Apple, but I'm not using anything undocumented, so I don't see what would cause an issue.
Enjoy!