How to increase Size of popOverView in iPad? - ios

I ma Using Following code to pop photo library in ipad..
[[UIImagePickerController alloc] init];
videoPicker.delegate = self;
videoPicker.sourceType =
UIImagePickerControllerSourceTypePhotoLibrary;
videoPicker.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage,(NSString *)kUTTypeMovie,nil];
videoPicker.allowsEditing = YES;;
pop = [[UIPopoverController alloc]initWithContentViewController:videoPicker];
[pop setDelegate:self];
[pop presentPopoverFromRect:[sender frame] inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
[videoPicker release];
How to increase the size of popOverView in this?

The popoverContentSize property controls the size of the popover content view.

Related

UIImagePickerController in UINavigationController

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];
}
}

Create UISegementControl and UIImagePicker in same UIPopoverController

I am creating a UISegementControl in UIPopoverController. How can i add UIImagePicker in that same UIPopoverController.
segmentController *segmentCtrl = [[segmentController alloc] init];
UINavigationController *navCtrl = [[UINavigationController alloc] initWithRootViewController:segmentCtrl];
UIImagePickerController *imgPicker = [[UIImagePickerController alloc] init];
[imgPicker setDelegate:self];
UIPopoverController *popOver = [[UIPopoverController alloc] initWithContentViewController:navCtrl];
[popOver setPopoverContentSize:CGSizeMake(300, 500) animated:YES];
popOver.delegate = self;
self.popoverImageViewController = popOver;
[self.popoverImageViewController presentPopoverFromBarButtonItem:button permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
In the above code It's create a UISegementControl in UIPopoverController. But i need to add also UIImagePicker in that UIPopover...
If i made any mistake. Please correct me.
Try doing something like this.
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
UIViewController *containerController = [[UIViewController alloc] init];
containerController.contentSizeForViewInPopover = CGSizeMake(768, 1000);
NSArray *itemArray = [NSArray arrayWithObjects: #"One", #"Two", #"Three", nil];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:itemArray];
[containerController.view addSubview:imagePickerController.view];
[containerController.view addSubview:segmentedControl];
popoverController = [[UIPopoverController alloc] initWithContentViewController:containerController];
[popoverController presentPopoverFromRect:selectedRect inView:self.view permittedArrowDirections:4 animated:YES];
//add ur segment control on top it would take 44 px then adjust the imagePicker frame accordingly.
CGRect tFrame = containerController.view.frame;
tFrame.origin.x -= 44;
tFrame.size.height -=44;
[imagePickerController.view setFrame:containerController.view.frame];

how to load Video from ipad library in ipad app

I have an iPad app in which when I click on the button it opens a popover with the iPad library to see the photos and pics. I want that when I click the button it should also show video in that but it does not show videos.
In device when I see library it shows videos but when popover opens in app it does not show any video.
UIImagePickerController *pckrImage = [[UIImagePickerController alloc] init];
pckrImage.delegate = self;
if (isiPhone) {
if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary]) {
pckrImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:pckrImage animated:YES];
}
}
else {
popOver = [[UIPopoverController alloc]initWithContentViewController:pckrImage];
[popOver presentPopoverFromRect:CGRectMake(450.0f, 825.0f, 10.0f, 10.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
First Create normal popover then add this code to for button 'choose photo from gallery'
UIImagePickerController *imagePicker1 = [[UIImagePickerController alloc] init];
imagePicker1.contentSizeForViewInPopover=CGSizeMake(300, 200);
imagePicker1.delegate = self;
imagePicker1.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
Popcontroller = [[UIPopoverController alloc] initWithContentViewController:imagePicker1];
[Popcontroller presentPopoverFromRect:cell1.ButtonAddPicture.frame
inView:cell1.ButtonAddPicture.superview
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
and for video add following line to above code
imagePicker1.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie];

UIIMagePicker on iPad to view photoLibrary crash

Im trying to get my imagePicker to load photos from my sourceLibrary. With the following code the app crashes with the following message 'Application tried to present modally an active controller'
-(void)viewPhotoLibrary{
NSLog(#"get photos");
UIImagePickerController *imagePickerController =
[[UIImagePickerController alloc] init];
UIPopoverController *pop = [[UIPopoverController alloc]
initWithContentViewController:imagePickerController];
pop.delegate = self;
[pop setPopoverContentSize:CGSizeMake(500, 500)];
[pop presentPopoverFromRect:
CGRectMake(0, 0, 500, 500)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
[imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[imagePickerController setDelegate:self];
[imagePickerController setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:imagePickerController animated:YES completion:nil];
}
comment the code
[imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[imagePickerController setDelegate:(id)self];
[imagePickerController setModalPresentationStyle:UIModalPresentationFullScreen];
[self presentViewController:imagePickerController animated:YES completion:^{
}];
or use this code
-(void)viewPhotoLibrary{
NSLog(#"get photos");
UIImagePickerController *imagePickerController =
[[UIImagePickerController alloc] init];
UIPopoverController *pop = [[UIPopoverController alloc]
initWithContentViewController:imagePickerController];
pop.delegate = self;
[pop setPopoverContentSize:CGSizeMake(500, 500)];
[pop presentPopoverFromRect:
CGRectMake(0, 0, 500, 500)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}

how to display cameracview in popOvewView in ipad

Hi for all i am using popoverController displaying for camera view but i am not getting camera view anybody please help me here s my code.
picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls=NO;
picker.delegate = nil;
picker.allowsEditing = NO;
UIViewController *containerController = [[UIViewController alloc] init];
containerController.contentSizeForViewInPopover = CGSizeMake(768, 750);
[containerController.view addSubview:picker.view];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:containerController];
self.popoverController = popover;
popoverController.delegate = self;
[popover release];
CGPoint point = {760,750};
CGSize size = {760,750};
[popoverController presentPopoverFromRect:CGRectMake(point.x, point.y, size.width, size.height)
inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
here i am getting empty popoverView? video is not displayed.
I couldn't find the issue. Please check with this code:
picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls=NO;
picker.delegate = nil;
picker.allowsEditing = NO;
picker.contentSizeForViewInPopover = CGSizeMake(768, 750);
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:picker];
self.popoverController = popover;
popoverController.delegate = self;
[popover release];
CGPoint point = {760,750};
CGSize size = {760,750};
[self.popoverController presentPopoverFromRect:CGRectMake(point.x, point.y, size.width, size.height) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

Resources