What's new

Issue with UIPopoverController

Sarvesh

iPF Noob
I have one UIButton on my screen. On selecting/clicking this Button I am opening list of Items in UIPopoverController. When I select item form UIPopoverController, the program works as intended without any issue. The problem occurs when instead of selecting item form UIPopoverController, if I click on screen, screen just turns blank, loosing all the content and controls from the screen. What could be the problem?
 
Essentially there are two code flows:

1. When an event occurs in the popover controller
2. When you tap outside popover.

In case one 1. you are dismissing the popover yourself.

In case of 2. the popover is dismissed for you. I would look at the code which does processing of events when the popover is dismissed (there is a delegate for that) to see if you are not removing the views.

Perhaps you have separate case for dismissed vs. selected? I would start there.
 
In my case problem occurs when I tap outside the popover.
Here is the part of code from .m file

invokeFilterModal methods brings up popover.

-(void) invokeFilterModal:(id) sender
{

if (self.popoverController == nil)
{

m_popoverList = [[WOPopOverList alloc] init];

UIPopoverController *popover =
[[UIPopoverController alloc] initWithContentViewController:m_popoverList];

popover.popoverContentSize = CGSizeMake(300.0f, 200.0f);
popover.delegate = self;
m_popoverList.delegate = self;

self.popoverController = popover;
[popover release];
}

CGRect popoverRect = [self.view convertRect:[btn frame]
fromView:[btn superview]];
popoverRect.size.width = MIN(popoverRect.size.width, 100);

self.popoverController.delegate = self;
[self.popoverController
presentPopoverFromRect:CGRectMake(195,-20,100,100)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
}


- (void) ProcessAfterSelectingItem:(NSString *) filterType
{

if (popoverController != nil)
{
[popoverController dismissPopoverAnimated:YES];
[m_btnFilter setTitle:filterType forState:UIControlStateNormal];
if([filterType isEqualToString:@"Name"])
m_strFilterType = @"NameWS";
else if([filterType isEqualToString:@"Number"])
m_strFilterType = @"NumberWS";
}
}


- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController {
[self.view removeFromSuperview];
NSLog(@"popover about to be dismissed");
return YES;
}


- (void)popoverControllerDidDismissPopover:
(UIPopoverController *)popoverController
{

NSLog(@"popover dismissed");
}


- (void)setDetailItem:(id)newDetailItem {

if (popoverController != nil) {
[popoverController dismissPopoverAnimated:YES];
}

self.popoverController = nil;

}


Thanks
 

Most reactions

Latest posts

Back
Top