问题
I've seen some demos where UIPopoverController is used and would like to use it in my apps.
So does anyone have any good tutorials that you could link me?
Is it possible to use it in relation to UISegmentedControl where different popover windows are summoned when different segments are selected as a type of a switch view function?
回答1:
Here are some tutorials:
- iPad for iPhone Developers 101: UIPopoverController Tutorial
- [iPad App Video] iPad App Tutorial – UIPopoverController
Segmented Popover:
- Using a UISegmentedControl in the footer of UIPopoverController
- Buttons inside of a Pop Over Controller on the iPad, no UISegmentUISegmentedControl used but looks like one
回答2:
For popover in iPad we can use ActionSheetStringPicker, and for implementing it in your project you need to import ActionSheetStringPicker into your controller. like - #imaport "ActionSheetStringPicker.h"
After importing this you have to create an array which has only string type value.
e.g.
NSArray *sourceArray=[[NSArray alloc]initWithObjects:@"Take Photo",@"Choose Photo", nil];
And last you have to implement below method.
[ActionSheetStringPicker showPickerWithTitle:@"Any title" rows:sourceArray initialSelection:yourInitialSelectionIntValue doneBlock:^(ActionSheetStringPicker *picker, NSInteger selectedIndex, id selectedValue) { NSLog(@" Index : %ld, value : %@", (long)selectedIndex, selectedValue); if ([selectedValue isEqualToString:@"Choose Photo"]) { // open photo lib [self youerMethdeOpenPhotoLib]; } else { // open Camera [self yourMethodOpenCamera]; } } cancelBlock:^(ActionSheetStringPicker *picker) { NSLog(@"Select photo Cancel"); }origin:YourTapButtonObject];
来源:https://stackoverflow.com/questions/5744434/are-there-examples-of-how-to-use-uipopovercontroller-on-ios