大佬教程收集整理的这篇文章主要介绍了iOS UITableViewCell内容在第一次滚动时移动,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我不知道从哪里开始,我怎么抓住这个小故障?
- (void)scrollTableToFixGlitch { [self.tableView setContentOffset:CGPointMake(0,1)]; [self.tableView setContentOffset:CGPointMake(0,-1)]; } - (void)viewDidLoad { [super viewDidLoad]; [self scrollTableToFixGlitch]; }
还在调查这个问题.我已经尝试过通用的UITableViewCells,没有任何改变.看起来这是View Controller的根视图或tableview布局的问题,而不是表格单元格.
更新2.
我排除了所有动画的问题,问题出在某个不同的地区.这个故障很容易在一个简化的项目上重新创建.我的标签栏控制器基于MHCustomTabBarController,具有自定义segue和一些其他附加功能.这是你重建故障的方法.设置一个项目,其中您的初始VC嵌入在Navigation Controller中.下一个控制器MHCustomTabBarController或子类被推送到导航堆栈.选项卡栏中的第一个可见VC是通用表视图控制器.而已.只有在导航堆栈中按下标签栏控制器时才会出现毛刺.
-(void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; if (self.childViewControllers.count < 1) { [self performSegueWithIdentifier:@"viewController1" sender:[self.buttons objectATindex:0]]; } } -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if (![segue isKindOfClass:[MHTabBarSegue class]]) { [super prepareForSegue:segue sender:sender]; return; } self.oldViewController = self.desTinationViewController; //if view controller isn't already contained in the viewControllers-Dictionary if (![self.viewControllersByIdentifier objectForKey:segue.identifier]) { [self.viewControllersByIdentifier setObject:segue.desTinationViewController forKey:segue.identifier]; } [self.buttons SETVALue:@NO forKeyPath:@"SELEcted"]; [sender setSELEcted:YES]; self.SELEctedIndex = [self.buttons indexOfObject:sender]; self.desTinationIdentifier = segue.identifier; self.desTinationViewController = [self.viewControllersByIdentifier objectForKey:self.desTinationIdentifier]; [[NsnotificationCenter defaultCenter] postNotificationName:MHCustomTabBarControllerViewControllerChangedNotification object:nil]; }
@implementation MHTabBarSegue - (void) perform { MHCustomTabBarController *tabBarViewController = (MHCustomTabBarController *)self.sourceViewController; UIViewController *desTinationViewController = (UIViewController *) tabBarViewController.desTinationViewController; //remove old viewController if (tabBarViewController.oldViewController) { [tabBarViewController.oldViewController willMoveToParentViewController:nil]; [tabBarViewController.oldViewController.view removeFromSuperview]; [tabBarViewController.oldViewController removeFromParentViewController]; } desTinationViewController.view.frame = tabBarViewController.container.bounds; [tabBarViewController addChildViewController:desTinationViewController]; [tabBarViewController.container addSubview:desTinationViewController.view]; [desTinationViewController didMoveToParentViewController:tabBarViewController]; } @end
更新3
在我的研究过程中,我发现 – 当子控制器出现时,第一次不调用viewWillAppear.但它随后被称为.
self.scrollView.alwaysBounceHorizontal = NO;
如果这不起作用,解决方案是在UIScrollView委托的帮助下以编程方式禁用水平滚动
self.scrollView.delegate = self; [self.scrollView setShowsHorizontalScrollInDicator:NO]; //for the below UIScrollView delegate function to work do the necessary step in the bottom of my answer. -(void)scrollViewDidScroll:(UIScrollView *)scrollView { if (scrollView.contentOffset.x > 0) scrollView.contentOffset = CGPointMake(0,scrollView.contentOffset.y); }
在.h文件中,您应该通过添加UIScrollViewDelegate将接口行更改为下面的行
@interface ViewController : UIViewController <UIScrollViewDelegate>
以上是大佬教程为你收集整理的iOS UITableViewCell内容在第一次滚动时移动全部内容,希望文章能够帮你解决iOS UITableViewCell内容在第一次滚动时移动所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。