UIPopovercontroller disconnected from UIButton

I have a problem with a separate UIPopovercontroller, and I hope someone already saw this behavior.

My application runs in landscape mode and offers several popover elements using the presentPopoverFromRect call. Some of them start from the top of the screen, and others from a view that is deeply immersed in the screen. Popsors seems to work fine if popover is presented from the top 2 / 3rds of the iPad display, however, when you try to run popover from the bottom 1/3 of the display, the popover is displayed separately from UIButton. The x coordinate seems correct, but the y coordinate of the popcorn tends to be in the middle or top of the iPad screen.

I played with the popover view using a fixed position, creating a CGRect object at the bottom of 1/3 of the screen, but when the iPad displays a popover, it either displays a popover at the top 2/3 or at the very bottom of the screen (if the CGRect value changes to a large y value )

At this moment I have no ideas and I hope that someone on the forum sees this or can make suggestions as to what to try.

Thanks for any help, Wes

+4
source share
1 answer

I managed to fix my problem and thought that I would share my solution if someone else had the same problem.

The solution was to add a call to set the size of the popover before calling presentPopoverFromRect.

[mySettingsPopoverController setPopoverContentSize:CGSizeMake(320, 320) animated:YES]; [mySettingsPopoverController presentPopoverFromRect:sender.frame inView:self.navigationButtonsView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; 

I used to not set the size of the popover content before the popover view. In the viewDidAppear method of the popover view manager, I resized the popover to size on the tableview in popover. Apparently, without setting popovercontentsize before the popover view, you get undefined behavior, including the ability to detach the popover from the element to which it should be attached.

Wes

+3
source

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


All Articles