in iOS8: UIPopoverController presentPopoverFromRect not work for keyWindow any more

后端 未结 4 1537
臣服心动
臣服心动 2021-02-05 12:03

As titled, in iOS8, [UIPopoverController presentPopoverFromRect] does not work for [UIApplication sharedApplication].keyWindow any more. (It does work in iOS7)

I verifi

4条回答
  •  终归单人心
    2021-02-05 12:33

    Change the inView parameter in

    [testPopoverController presentPopoverFromRect:rect inView:[UIApplication sharedApplication].keyWindow permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
    

    to

    [testPopoverController presentPopoverFromRect:rect inView:"your current View Controller's view" permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
    

    And make sure it is in dispatch block

      dispatch_async(dispatch_get_main_queue(), ^{
    

    });

    Also kip changing your rect origin n size values if it is within the bounds

提交回复
热议问题