IOS UITableViewCell Content Scrolls First Scroll

You can see in the gif below that in the first scroll of the contents of the cell, the UITableView moves a bit. You can hardly see it, the fields are getting 1 pixel wider. I have never encountered this before. It seems that there is some kind of layout before the first scroll, and he himself decides after this fact. There are no warnings in Xcode, these custom cells are pretty simple, without overriding the layout code.

I don’t know where to start, how do I catch this glitch?

UPDATE I implemented an obvious workaround:

- (void)scrollTableToFixGlitch {

   [self.tableView setContentOffset:CGPointMake(0, 1)];
   [self.tableView setContentOffset:CGPointMake(0, -1)];

}
- (void)viewDidLoad {

   [super viewDidLoad];

   [self scrollTableToFixGlitch];
}

Still studying the problem. I tried the general UITableViewCells, nothing has changed. It seems like a problem with the view view root view or the table view, and not the table cells.

2.

, - . . My Tab Bar MHCustomTabBarController . , . , VC . MHCustomTabBarController, . VC Table View Controller. . Glitch , .

, , , :

-(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]; 


}

segue:

@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 , . .

enter image description here

+4
2

, , , . , - , . 3, , -viewWillAppear TableViewController, TabBarController . SO, .

, , :

    //added this line
    [destinationViewController viewWillAppear:YES];

    [tabBarViewController.container addSubview:destinationViewController.view];

, ! , .

, -navigationController: willShowViewController: : UINavigationControllerDelegate.

. , - .

, . -viewWillAppear , . TableViewController. NavigationControllerDelegate. segue .

0

, scrollviews contentSize , scrollView ( ), . contentSize

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>

, , : D

+1

All Articles