I am loading a popover view that displays the camera view. everything works however it dose not dsplay any bigger than a playing card on the iPad. No matter what I do I cannot resize it only change its position.
This is the code I use
[self.popOver presentPopoverFromRect:CGRectMake(44, 6, 111, 111) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
How can I adjust the size?
Update
This is what my whole method looks like:
- (void) cameraButtonSelected
{
// create picker
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.preferredContentSize = CGSizeMake(400.0, 400.0);
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
CGFloat scaleFactor=1.3f;
picker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * -90 / 180.0), scaleFactor, scaleFactor);
}
// create popover
self.popOver = [[UIPopoverController alloc] initWithContentViewController:picker];
[self.popOver presentPopoverFromRect:CGRectMake(44, 6, 111, 111) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
try settings this property to the controller contained in popover
someViewController.contentSizeForViewInPopover = CGSizeMake(200.0, 200.0)
try using
preferredContentSize
property.
sorry I don't have a mac on me to check it
You should try to set the size in viewWillAppear:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.popover.preferredContentSize = ...
}
Nothing worked for me, so I resized the popoverController after displaying it like this:
[popoverController presentPopoverFromRect:cell.mediaComment.frame
inView:cell
permittedArrowDirections:UIPopoverArrowDirectionRight
animated:YES];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
popoverController.contentViewController.preferredContentSize = REQUIRED_RECT.size;
popoverView.frame = REQUIRED_RECT;
});
Related
Guyz, I am displaying UIImagePickerController in UINavigationController but some frame of image picker controller hides under nav bar .Do any Body has the solution and code is
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];
//[picker.view setFrame:CGRectMake(0,50, 800, 600)];
self.nv=[[UINavigationController alloc]init];
[self.nv.view setFrame:(CGRectMake(0, 50, 320.0, 400.0))];
// 4. add the nav bar to the main view
[self.nv addChildViewController:picker];
[picker didMoveToParentViewController:self.nv];
picker.view.frame = CGRectMake(15, 50, 290, 400);
popoverController = [[UIPopoverController alloc] initWithContentViewController:self.nv];
[popoverController presentPopoverFromRect:[(UIButton *)sender frame]
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
Try this alternate. :)
#define ISIPHONE [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone
UIPopoverController *popover;
- (IBAction)openImagePicker:(UIButton *)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //UIImagePickerControllerSourceTypeCamera
if (ISIPHONE)
{
[self presentViewController:picker animated:YES completion:NULL];
}
else
{
if (!popover)
{
popover = [[UIPopoverController alloc] initWithContentViewController:picker];
}
[popover presentPopoverFromRect:sender.bounds inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
I want to make a popover to fullscreen
popover = [[UIPopoverController alloc] initWithContentViewController:cameraUI];
[_popover presentPopoverFromRect:CGRectMake(0, 0, 0, 0) inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUnknown animated:YES];
who know how to do it in ios7/ios8
well anyway if your problem is it's not working on a phone then add a category like this
#interface UIPopoverController (phone)
+ (BOOL)_popoversDisabled;
#end
#implementation UIPopoverController (phone)
+ (BOOL)_popoversDisabled {
return NO;
}
#end
then doing a popover like this seems just fine. so again, not sure what your actual problem is (if any)
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,nil];
imagePicker.allowsEditing = NO;
UIPopoverController * popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[popover presentPopoverFromRect:CGRectMake(0, 0, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUnknown animated:YES];
I am loading a UIPopoverController that contains a UIImagePickerController, when the view loads it loads a seethrough view behind the popover, which if touched it dismisses the popover and the the cameraview inside it.
I would like to know if there is a way to remove this background view and control the dismiss myself with buttons.
My goal is to have some information to the left and the camera popover view to the right, but I cannot do this as some of the information is selectable i.e. textfields, and currently this background view is preventing selection of them.
This is my code for the popovercontroller and the UIImagePickerController.
- (void) cameraButtonSelected
{
// set background
UIView *cameraBG = [[UIView alloc] initWithFrame:CGRectMake(0.0, 20.0, screenHeight, screenWidth-64)];
cameraBG.backgroundColor = [UIColor blackColor];
cameraBG.alpha = 0.8;
[self.view addSubview:cameraBG];
// create picker
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
CGFloat scaleFactor=1.3f;
picker.cameraViewTransform = CGAffineTransformScale(CGAffineTransformMakeRotation(M_PI * -90 / 180.0), scaleFactor, scaleFactor);
}
// create popover
self.popOver = [[UIPopoverController alloc] initWithContentViewController:picker];
[self.popOver presentPopoverFromRect:CGRectMake(500, 100, 0, 0) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:NO];
}
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
viewController.preferredContentSize = CGSizeMake(805, 650);
}
You can just call,
self.popOver.hidden = YES; or self.popOver.hidden = NO;
If you want the pop0ver view to still be drawn but still hidden to the user, you can call self.pop0ver.alpha = 0.0f;
I can't set data inside the viewController "searchController" managed by a UIPopoverController:
in viewDidLoad i have:
searchController = [[PopOverSearchController alloc] initWithNibName:#"PopOverSearchController" bundle:nil];
popoverController = [[UIPopoverController alloc] initWithContentViewController:searchController];
I do a method for call this popover that work fine:
if ([popoverController isPopoverVisible]) {
[popoverController dismissPopoverAnimated:YES];
} else {
searchController.data = data;
[searchController.tableResult reloadData];
CGRect popRect = CGRectMake(self.searchBar.frame.origin.x,
self.searchBar.frame.origin.y +15,
self.searchBar.frame.size.width,
self.searchBar.frame.size.height);
[popoverController presentPopoverFromRect:popRect
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
[searchController.tableResult reloadData]; was not called: the popup appear (above the search bar )but with an empty table
How to add UIImagePickerViewController as a subview in ipad.
in iphone i used like this this working fine
self.pick = [[UIImagePickerController alloc]init];
pick.delegate = self;
pick.sourceType = UIImagePickerControllerSourceTypeCamera;
pick.sourceType = UIImagePickerControllerCameraDeviceFront;
pick.showsCameraControls = NO;
CGRect rect = CGRectMake(0, 0, 200, 250);
pick.view.frame = rect;
UIView *cameraView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 200, 200)];
[cameraView setBackgroundColor:[UIColor greenColor]];
[cameraView addSubview:pick.view];
[self.view addSubview:cameraView];
[pick viewWillAppear:YES];
[pick viewDidAppear:YES];
[pick release];
but same way i pad is not working. ipad is getting full view when camera is open.
i don't want to use popoverview controller.
pls help me?
UIImagePickerController must be presented with UIPopoverController on iPad.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
[popover presentPopoverFromRect:self.selectedImageView.bounds inView:self.selectedImageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
self.popOver = popover;
} else {
[self presentModalViewController:picker animated:YES];
}