1

我正在创建一个UISegementControlin UIPopoverController. 我怎样才能添加UIImagePicker相同的内容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];

在上面的代码中,它UISegementControl在 UIPopoverController 中创建了一个。但我还需要在 UIPopover 中添加 UIImagePicker ...

如果我犯了任何错误。请纠正我。

4

1 回答 1

0

尝试做这样的事情。

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];
于 2013-09-19T04:24:35.210 回答