{"action":"created","issue":{"url":"https://api.github.com/repos/wangmchn/WMPageController/issues/43","labels_url":"https://api.github.com/repos/wangmchn/WMPageController/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/wangmchn/WMPageController/issues/43/comments","events_url":"https://api.github.com/repos/wangmchn/WMPageController/issues/43/events","html_url":"https://github.com/wangmchn/WMPageController/issues/43","id":122690578,"number":43,"title":"如何实现向子控制器传值","user":{"login":"duanyicanyuan","id":16026959,"avatar_url":"https://avatars.githubusercontent.com/u/16026959?v=3","gravatar_id":"","url":"https://api.github.com/users/duanyicanyuan","html_url":"https://github.com/duanyicanyuan","followers_url":"https://api.github.com/users/duanyicanyuan/followers","following_url":"https://api.github.com/users/duanyicanyuan/following{/other_user}","gists_url":"https://api.github.com/users/duanyicanyuan/gists{/gist_id}","starred_url":"https://api.github.com/users/duanyicanyuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duanyicanyuan/subscriptions","organizations_url":"https://api.github.com/users/duanyicanyuan/orgs","repos_url":"https://api.github.com/users/duanyicanyuan/repos","events_url":"https://api.github.com/users/duanyicanyuan/events{/privacy}","received_events_url":"https://api.github.com/users/duanyicanyuan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-17T09:00:50Z","updated_at":"2015-12-18T00:51:26Z","closed_at":null,"body":"通过设置values和keys向子控制器传值。(内部利用KVC实现)"},"comment":{"url":"https://api.github.com/repos/wangmchn/WMPageController/issues/comments/165626825","html_url":"https://github.com/wangmchn/WMPageController/issues/43#issuecomment-165626825","issue_url":"https://api.github.com/repos/wangmchn/WMPageController/issues/43","id":165626825,"user":{"login":"duanyicanyuan","id":16026959,"avatar_url":"https://avatars.githubusercontent.com/u/16026959?v=3","gravatar_id":"","url":"https://api.github.com/users/duanyicanyuan","html_url":"https://github.com/duanyicanyuan","followers_url":"https://api.github.com/users/duanyicanyuan/followers","following_url":"https://api.github.com/users/duanyicanyuan/following{/other_user}","gists_url":"https://api.github.com/users/duanyicanyuan/gists{/gist_id}","starred_url":"https://api.github.com/users/duanyicanyuan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duanyicanyuan/subscriptions","organizations_url":"https://api.github.com/users/duanyicanyuan/orgs","repos_url":"https://api.github.com/users/duanyicanyuan/repos","events_url":"https://api.github.com/users/duanyicanyuan/events{/privacy}","received_events_url":"https://api.github.com/users/duanyicanyuan/received_events","type":"User","site_admin":false},"created_at":"2015-12-18T00:51:26Z","updated_at":"2015-12-18T00:51:26Z","body":" WMPageController *pageVC = [[WMPageController alloc] initWithViewControllerClasses:viewControllers andTheirTitles:titles];\r\n// 初始化时给keys和values在这边赋值\r\n    pageVC.keys = [NSArray arrayWithObjects:@\"selectIndex\", @\"selectIndex\", @\"selectIndex\", @\"selectIndex\", nil];\r\n    pageVC.values = [NSArray arrayWithObjects: @\"0\", @\"1\", @\"2\", @\"3\", nil];\r\n    pageVC.pageAnimatable = YES;\r\n    pageVC.menuItemWidth = 85;\r\n    pageVC.postNotification = YES;\r\n    pageVC.bounces = YES;\r\n\r\n// 自控制器，这样设置\r\n@interface OrderDetailVC : UITableViewController\r\n\r\n@property (nonatomic, copy)NSString *selectIndex;\r\n@end\r\n\r\n\r\n为什么会在WMPageController.m中\r\n// 添加子控制器\r\n- (void)addViewControllerAtIndex:(int)index {\r\n    Class vcClass = self.viewControllerClasses[index];\r\n    UIViewController *viewController = [[vcClass alloc] init];\r\n    if (self.values.count == self.viewControllerClasses.count && self.keys.count == self.viewControllerClasses.count) {\r\n//   会在下面这段代码崩溃\r\n        [viewController setValue:self.values[index] forKey:self.keys[index]];\r\n    }\r\n    [self addChildViewController:viewController];\r\n    viewController.view.frame = [self.childViewFrames[index] CGRectValue];\r\n    [viewController didMoveToParentViewController:self];\r\n    [self.scrollView addSubview:viewController.view];\r\n    [self.displayVC setObject:viewController forKey:@(index)];\r\n    [self backToPositionIfNeeded:viewController atIndex:index];\r\n}"}}