我有一个UIPopover,里面有一个打开ABPeoplePicker的按钮。我把它打开了弹出窗口,但它转移了。它不会停留在同一个位置,尺寸会改变,我如何保持它的大小相同。
//调用popover的代码
- (IBAction) addPerson:(id) sender{
// create your view controller if it doesn't exist yet
if (addPersonViewController == nil){
addPersonViewController = [[addPersonViewControllerPopover_iPad alloc] init];
}
pop = [[UIPopoverController alloc] initWithContentViewController:addPersonViewController];
// rest of your method...
addPersonViewController.delegate = self;
pop.popoverContentSize = CGSizeMake(320, 480);
CGRect rect = CGRectMake(790, 35, 175, 300);
[pop presentPopoverFromRect:rect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
[addPersonController retain];
NSLog(@"this one");
}
// popover code
- (IBAction) AddButtonAction:(id)sender {
picker = [[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
picker.navigationBar.tintColor = [UIColor brownColor];
picker.contentSizeForViewInPopover = CGSizeMake(320, 480);
picker.modalPresentationStyle = UIModalPresentationCurrentContext;
picker.modalInPopover = YES;
// Display only a person's phone, email, and birthdate
NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty],
[NSNumber numberWithInt:kABPersonEmailProperty],
[NSNumber numberWithInt:kABPersonBirthdayProperty], nil];
picker.displayedProperties = displayedItems;
//Show the picker
[self presentModalViewController:picker animated:YES];
[picker release];
}
答案 0 :(得分:0)
你需要这样做
picker.modalPresentationStyle = UIModalPresentationCurrentContext;