I have UILabel, hardWayLabel , inside a UIView, hardWayView . I need this view (and therefore the shortcut) to animate a new position on the left side of the screen. However, while the mark is in the correct position, the view can be seen while continuing to move far from the left side of the screen. I use the following code for animation (which I use many times in my application successfully):
CGRect frame = hardWayView.frame; frame.origin.x = painPoint.x; frame.origin.y = painPoint.y; hardWayView.frame = frame; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:.25];
I used NSLog to make sure that painPoint.x and painPoint.y are what they should be 9, which is confirmed by the fact that UILabel is in the correct position. I guess the real question is why will the UIView continue to move past the edges of the screen (and only in this case, when the UIView is animating to the left from the center of the screen)?
I have Autolayout turned on, although I donβt think itβs a criminal. This problem occurs when I run the application on the iPhone Simulator with iOS 7, and I canβt get the simulator to work with iOS 6, so I canβt isolate the problem before iOS 7 (although maybe?) I started development in the old version of Xcode and the application do not use storyboards).
Here is the screen recording of the problem. As you can see, moving two images from left to right works fine. Although when moving the views to the left, one of the views (black background) seems to exit the screen in the upper left corner, while the label (in orange text) goes to the right place). Explanatory video
Update: here is some more code. It is almost identical to the other parts of my application that work flawlessly, which is a bit of a brain blaster.
NSString *stringOfRands = tDict[@"originalRand"]; if ([stringOfRands rangeOfString:@"+"].location != NSNotFound) { NSArray *arrayOfRands = [stringOfRands componentsSeparatedByString:@" + "]; for (int z=1; z<[arrayOfRands count]; z++) { NSString *updateValue = arrayOfRands[z]; NSInteger newHiddenPosition = [self findBlank:leftSpaces]; NSDictionary *updateStuff = @{@"updateValue": updateValue, @"workingMasterDict":tDict, @"newPos":@(newHiddenPosition), @"newCGPto":@"left", @"@parent":colorV}; [self revealHidden:updateStuff]; } }
I believe that the problem does occur during the revealHidden method, where the animation is called.
[leftSpaces replaceObjectAtIndex:[hardWayPos intValue] withObject:[NSString stringWithFormat:@"full"]]; CGPoint painPoint = [[leftPoints objectAtIndex:[hardWayPos intValue]] CGPointValue]; [UIView animateWithDuration:0.25 animations:^{ CGRect frame = hardWayView.frame; frame.origin.x = painPoint.x; frame.origin.y = painPoint.y; hardWayView.frame = frame; } completion:^(BOOL finished) {
I tried to make frame.origin.x and .y real numbers (compared to variables) and the same pattern: UILabel is animated to the right place, and UIView is animated in the upper left corner of the screen