1

I am having a design like below

enter image description here

As you can see, I'm using UIPopoverPresentationController when user tap on the UITableViewCell vertical three dots image. Following is my code for displaying that pop over presentation view controller.

- (void)showMoreOptionsRelatedToMediCard:(UITapGestureRecognizer *)tapRecognizer {

    selectedMedItemRowIntValue = (int)tapRecognizer.view.tag;

    MedItemPopOverViewController *medItemPopOverViewCont = viewControllerWithIdInStoryboard(medItemPopOverViewControllerId, MED_REMINDER_STORYBOARD);
    medItemPopOverViewCont.modalPresentationStyle = UIModalPresentationPopover;
    medItemPopOverViewCont.popoverPresentationController.delegate = self;

    [self presentViewController:medItemPopOverViewCont animated:NO completion:nil];

    UIPopoverPresentationController *popController = [medItemPopOverViewCont popoverPresentationController];
    popController.permittedArrowDirections = UIPopoverArrowDirectionRight;
    popController.delegate = self;

    popController.sourceView = tapRecognizer.view;

    popController.sourceRect = CGRectMake(30, 50, 10, 10);
}

Question 1.

Why the Medication tab index image is changes as not selected when the pop over presented?

As you can see the selected tab index title is highlighted but not the image. Because of that I believe, this is nothing to do with Alpha value in the presented view controller. But anyway I have given 1 as the alpha value for presented view.

Question 2.

When I tap some where else other than the pop over, then I get following warning in the Debug area in Xcode, even pop over has dismissed.

[Warning] <_UIPopoverBackgroundVisualEffectView 0x117931ed0> is being asked to animate its opacity. This will cause the effect to appear broken until opacity returns to 1.

Question 3.

As you can see in the image that I've uploaded, I'm using a table view inside my pop over view. When a user tap on any cell in that table, I'm calling following code to dismiss the pop over inside didSelectRowAtIndexPath method

[self dismissViewControllerAnimated:NO completion:nil];

Is that the correct way of dismissing a presented view. Because, it does actually dismiss the presented view but ended up with the same result that I've mentioned in the first question, which is tab index image is not highlighted.

I believe all these three questions is having a connection. That's why I box them in one SO question.

4

1 回答 1

0

试试下面的链接,它可能对你有用https://www.invasivecode.com/weblog/uipopoverpresentationcontroller-uisearchcontroller

对于问题 1. 在标签栏类中添加以下行

 [[UITabBar appearance] setTintColor:[UIColor colorWithRed:redColor]];//Add your color here

问题2。

- (void)showMoreOptionsRelatedToMediCard:(UITapGestureRecognizer *)tapRecognizer {

    selectedMedItemRowIntValue = (int)tapRecognizer.view.tag;

    MedItemPopOverViewController  *medItemPopOverViewCont = viewControllerWithIdInStoryboard(medItemPopOverViewControllerId, MED_REMINDER_STORYBOARD);

    medItemPopOverViewCont.modalPresentationStyle = UIModalPresentationPopover;


    UIPopoverPresentationController *popController = [medItemPopOverViewCont popoverPresentationController];

    popController.sourceRect = CGRectMake(30, 50, 10, 10);

    popController.sourceView = tapRecognizer.view;

    popController.permittedArrowDirections = UIPopoverArrowDirectionRight;

    popController.delegate = self;

   [self presentViewController: medItemPopOverViewCont animated:YES completion:nil];

}
于 2017-09-04T07:29:50.430 回答