UIPopoverController weird behavior

I use the UIPopoverController and populate it with the MPMediaPickerController to select songs from the iPod library. Everything works fine for me. However, I added a completely unrelated function (touch the button and the image scale to a large size), and now the UIPopoverController behaves strangely only after using the new function.

After using the button zoom function, the UIPopoverController appears in a strange way. It appears to be animated from a turn from the screen and lands in the right place, but the expected behavior is that it should just appear in the right place.

// code for if the interface is a an iPhone, do not use popup if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) [self presentModalViewController:picker animated:YES]; 

// code if iPhone does not use popover media picker

 else { UIPopoverController* pop = [[UIPopoverController alloc] initWithContentViewController:picker]; self.currentPop = pop; 

// checks if the iPad is portrait or landscape, and displays the popover media collector accordingly

  if (vertMode == TRUE) { 

// if in portrait mode

  [pop presentPopoverFromRect:CGRectMake(668.0f, 846.0f, 10.0f, 10.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:NO]; 

// otherwise, if in landscape mode

  } else if (vertMode == FALSE) { [pop presentPopoverFromRect:CGRectMake(900.0f, 580.0f, 10.0f, 10.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:NO]; } [pop release]; } 

}

+4
source share
1 answer

Well, I feel a little silly when I answer my question, but I hope this can help someone else in the future.

I'm not quite sure why, but in my function for a button that scales the image to a large size, I forgot to add:

  [UIView commitAnimations]; 

the intention was to complete the animated movement of the zooming image, I guess, because I never make an animation that is still in some state trying to animate things. Then, when I called up my popup, it created a weird animation.

So I fixed this by simply adding one line above!

I feel it is much better to understand this! Hope this helps someone else.

+2
source

Source: https://habr.com/ru/post/1388570/


All Articles