dimanche 25 janvier 2015

UIPopoverController for Iphone

I'm trying to make a UIPopover in the iphone. I have a xib file with a UIView and a textView inside.


I did some research and I came up with this workaround:



//UIPopover+Iphone.h
@interface UIPopoverController (overrides)
+ (BOOL)_popoversDisabled;
@end

//UIPopover+Iphone.m
@implementation UIPopoverController (overrides)
+ (BOOL)_popoversDisabled {return NO;}
@end


Here is my actual code:



- (IBAction)info:(id)sender
{
popViewController *popVC = [[popViewController alloc] initWithNibName:@"popViewController" bundle:nil];

self.pop = [[UIPopoverController alloc] initWithContentViewController:popVC];
[self.pop setDelegate:self];

[self.pop setPopoverContentSize:CGSizeMake(220, 110) animated:YES];
[self.pop presentPopoverFromRect:[(UIButton *)sender frame] inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
}


The problem is, when I run the app and press the button, the view in the xib fills up the whole page.


I then tried programmatically setting the size of popVC like so:



[vc.view setFrame:CGRectMake(0, 0, 220, 110)];


And the same thing happened.




Aucun commentaire:

Enregistrer un commentaire