这可能看起来像以前问过的问题(PageViewController委托函数调用了两次),但问题是我无法将该解决方案应用于我的问题.
您可能会注意到我正在开发一个日历应用程序并使用UIPageViewController来管理我的年度日历显示.正如您所看到的,我正在使用UIPageViewControllerTransitionStylePageCurl,当用户卷曲页面(向前/向后)时,它们各自的委托被调用两次,这将根据执行的委托给我2年递增或递减.现在我需要找出导致此问题的原因并阻止它执行两次.
我知道在那些给出我的下一页或上一页的委托中返回一个viewController是很重要的,因此我只是刷新了viewController的视图,以便我可以用新数据渲染视图.我也试过其他代表呼吁willTransitionToViewControllers但不会让我在任何地方,因为willTransitionToViewControllers只会viewControllerAfterViewController和viewControllerBeforeViewController后得到执行.
有人帮我理解并解决了这个问题.
- (void)addCalendarViews
{
CGRect frame = CGRectMake(0., 0., self.view.frame.size.width, self.view.frame.size.height);
pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStylePageCurl
navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal
options:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:UIPageViewControllerSpineLocationNone] forKey:UIPageViewControllerOptionSpineLocationKey]];
pageViewController.doubleSided = YES;
pageViewController.delegate = self;
pageViewController.dataSource = self;
YearCalendarViewController *yearController = [[YearCalendarViewController alloc] init];
NSArray *viewControllers = [NSArray arrayWithObject:yearController];
[self.pageViewController setViewControllers:viewControllers
direction:UIPageViewControllerNavigationDirectionReverse
animated:YES
completion:nil];
[self addChildViewController:pageViewController];
[self.view addSubview:pageViewController.view];
[pageViewController didMoveToParentViewController:self];
CGRect pageViewRect = yearController.view.bounds;
self.pageViewController.view.frame = pageViewRect;
viewCalendarMonth = [[SGMonthCalendarView alloc] initWithFrame:frame];
[self.view addSubview:viewCalendarMonth];
arrayCalendars = @[pageViewController.view, viewCalendarMonth];
}
-(UIViewController*)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController …Run Code Online (Sandbox Code Playgroud) 它仍然在ios 7中运行良好,UITextView被添加到popover并显示.
UITextView *textViewComment =[[UITextView alloc]init];
textViewComment.tag = 2001;
textViewComment.delegate = self;
textViewComment.frame=CGRectMake(15,60, 370,120);
textViewComment.contentInset = UIEdgeInsetsMake(5.0f, 5.0f, 5.0f, 0.0f);
[textViewComment setReturnKeyType:UIReturnKeyDone];
textViewComment.textAlignment = NSTextAlignmentLeft;
textViewComment.showsHorizontalScrollIndicator = NO;
textViewComment.bounces = NO;
textViewComment.layer.borderColor = [[UIColor lightGrayColor]CGColor];
textViewComment.layer.borderWidth =1.0f;
[textViewComment addSubview:commentPlaceHolderLabel];
[popupViewController.view addSubview:textViewComment];
Run Code Online (Sandbox Code Playgroud)
在ios8上添加textViewComment.keyBoardType = UIKeyboardAlphabet,textViewComment.enable = YES; 没有帮助.我不知道自己犯了什么错误.这是新的sdk bug吗?还是我的虫子?
提前致谢