2

i have a popoverview issues while click and open the camera for ipad,i wrote code like that

-(IBAction)business_takephotobtnClicked   // click the button show the popoverview

{ 

NSLog(@"business_takephotobtnClicked");
    appdelegate.takePhoto=2;

    popover = [[UIPopoverController alloc] 
               initWithContentViewController:imgclass];

    popover.popoverContentSize =  CGSizeMake(138,66);
    [popover presentPopoverFromRect:popbtn_business.bounds inView:popbtn_business 
    permittedArrowDirections:UIPopoverArrowDirectionUp + 
    UIPopoverArrowDirectionLeft 
    animated:YES]; 
}





-(IBAction) takePhoto:(id)sender // to open the camera

{




    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
    {

       self.contentSizeForViewInPopover=CGSizeMake(138,66);




        UIPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [self presentModalViewController:self.UIPicker animated:YES];

    }
    else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Camera is not available" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
        [alert show];
        [alert release];


    }

}

before click the button the popover like that showenter image description here

while click the take photo(Neem foto button).THE POPOVERVIEW SIZE IS AUTOMATICALLY EXTENTED like tahtenter image description here

But i need a same size popoverview while open the camera also

Thanks in Advance......

Dhruv
  • 2,153
  • 3
  • 21
  • 45
iCrazyDev
  • 925
  • 5
  • 16
  • check this link :-http://stackoverflow.com/questions/3458722/uipopovercontroller-automatically-resizing-to-max-height-on-pushviewcontroller – Leena Jul 27 '12 at 07:06

1 Answers1

5

instead of using XIB use to create the camera view programatically and do like the following

-(IBAction)popbtn_Click:(id)sender
{
    UIViewController* popoverContent = [[UIViewController alloc] init];
    UIView* popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 230, 180)];
    popoverView.backgroundColor = [UIColor whiteColor];

    take_btn=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    [take_btn setTitle:@"Take" forState:UIControlStateNormal];
    take_btn.frame=CGRectMake(2,2, 250, 60);
    [take_btn addTarget:self action:@selector(take_btnclick:) forControlEvents:UIControlEventTouchUpInside];
    [popoverView addSubview:take_btn];
}

-(void)take_btnclick:(id)sender
{
    [popoverController dismissPopoverAnimated:YES];

    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        UIPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [self presentModalViewController:self.UIPicker animated:YES];

        [popoverController dismissPopoverAnimated:YES];
    }
    else {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"Camera is not available" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }

    if (popoverController != nil)
    {
        [popoverController dismissPopoverAnimated:YES];
    }
}
Community
  • 1
  • 1
Veera Raj
  • 1,562
  • 1
  • 19
  • 40