UIPopover Help

Discussion in 'iPhone/iPad Programming' started by ahan.tm, Mar 14, 2012.

  1. macrumors regular

    #1
    Hi,

    I am creating popovers in my Universal application using th following code:
    Code:
     
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
           
            NSLog(@"iPhone");
            
            FlipsideViewController *controller = [[[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil] autorelease];
            controller.delegate = self;
            
            
            UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
            navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
            [self presentModalViewController:navController animated:YES];
            
            [navController release];
            [controller release];
        } 
        else{
                
            NSLog(@"iPad");
                
            FlipsideViewController *controller = [[[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil] autorelease]; 
            
            UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
    
            
            UIPopoverController *flipsidePopoverController = [[UIPopoverController alloc] initWithContentViewController:navController];
            
            //[self.flipsidePopoverController setDelegate:self];  
            
            if ([flipsidePopoverController isPopoverVisible]) {
                [flipsidePopoverController dismissPopoverAnimated:YES];
            } else {
                [flipsidePopoverController presentPopoverFromRect:[info bounds] inView:info permittedArrowDirections:UIPopoverArrowDirectionDown animated:NO];
                [flipsidePopoverController setPopoverContentSize:CGSizeMake(320.0, 480.0)];  
            }
            
            [controller release];
            
        }
    
    However, the flipside view has an add button that leads to another view using the following code:

    Code:
        AddViewController *addViewController = [[AddViewController alloc] initWithStyle:UITableViewStyleGrouped];
    	addViewController.delegate = self;
        
    
    	
    	// Create a new managed object context for the new book -- set its persistent store coordinator to the same as that from the fetched results controller's context.
    	NSManagedObjectContext *addingContext = [[NSManagedObjectContext alloc] init];
    	self.addingManagedObjectContext = addingContext;
    	
    	[addingManagedObjectContext setPersistentStoreCoordinator:[[fetchedResultsController managedObjectContext] persistentStoreCoordinator]];
        
    	addViewController.child = (Child *)[NSEntityDescription insertNewObjectForEntityForName:@"Child" inManagedObjectContext:addingContext];
    	
    	UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addViewController];
    	
        [self.navigationController presentModalViewController:navController animated:YES];
    	
    
    However, when I press the plus button, it opens full screen on the iPad. How do I get it to open inside the popover.

    Thanks:)
     

Share This Page