开发者

dismiss UIPopOverController from contentViewController

开发者 https://www.devze.com 2023-03-06 09:59 出处:网络
How can you dismiss a popover from the contentViewController, so in the example code I have below I would like to dismiss the UIPopOver from the ProfileViewController code. How do I do this? Another p

How can you dismiss a popover from the contentViewController, so in the example code I have below I would like to dismiss the UIPopOver from the ProfileViewController code. How do I do this? Another post similar to this suggested to use NSNotification, but how do use it?

- (void)profilePop:(UITapGestureRecognizer *)recognizer
{
    ProfileViewController * profile = [[ProfileViewController alloc] init];
    CGPoint location = [recognizer locationInView:self.table];
    NSIndexPath* indexPath = [self.table indexPathForRowAtPoint:location];
    开发者_Go百科ConvoreCell* cell = (ConvoreCell *) [self.table cellForRowAtIndexPath:indexPath];
    profile.uid =  [[[self.posts objectAtIndex:indexPath.row] creator] mid];
    UIPopoverController * profilePop  = [[UIPopoverController alloc] initWithContentViewController:profile];
    [profilePop setPopoverContentSize:CGSizeMake(350, 180)];
    [profilePop presentPopoverFromRect:CGRectMake(0,0, cell.avatar.frame.size.width, cell.avatar.frame.size.height) inView:cell permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
}


I would keep a reference to the popover in your profile class.

profile.popOver = profilePop;

then in the area you'de like to dismiss:

[self.popover dismissPopoverAnimated:YES];


I think keeping a reference is the way to go too, but I don't know if its a good idea to retain it, because when you need to release the popover controller it won't dealloc because there is an extra retain.

0

精彩评论

暂无评论...
验证码 换一张
取 消