Reputation: 5471
i am having little problem here. I have made a popout view activated on toolbard button click. However the view is not in the position i want. See screenshot
1st screen shows what i have and 2nd what i want.
btw: popview is done problematically. No xib or storyboard involved.
Some code
-(IBAction)addbutton:(UIToolbar *)sender;
{
//build our custom popover view
UIViewController* popoverContent = [[UIViewController alloc]
init];
UIView* popoverView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
popoverView.backgroundColor = [UIColor blackColor];
/*
* Adding buttons programaticly to popout view
* button code etc
*/
popoverContent.contentSizeForViewInPopover = CGSizeMake(400, 300);
//create a popover controller
self.popoverController = [[[UIPopoverController alloc]
initWithContentViewController:popoverContent] autorelease];
[popoverController presentPopoverFromRect:popoverButton.frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionLeft
animated:YES];
//release the popover content
[popoverView release];
[popoverContent release];
}
Thank you
Upvotes: 0
Views: 1332
Reputation: 53551
Your popoverButton
is probably not a subview of self.view
, so using its frame
relative to that will result in an incorrect rectangle. Use popoverButton.bounds
for the rectangle and popoverButton
for the fromView
parameter instead.
Note that the fromView
parameter does not determine in which view the popover will be shown (it'll always be on top of everything), but rather relative to which view's coordinate system the rectangle should be interpreted.
Upvotes: 2
Reputation: 4279
[popoverController presentPopoverFromRect:popRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
try to change frame popRect
.
Upvotes: 0