有没有关于如何在 iOS 上使用 UIPopoverController 的例子?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5744434/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Are there examples of how to use UIPopoverController on iOS?
提问by Nick Weaver
I've seen some demos where UIPopoverController is used and would like to use it in my apps.
我看过一些使用 UIPopoverController 的演示,并希望在我的应用程序中使用它。
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?
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?
回答by Nick Weaver
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
- 在 UIPopoverController 的页脚中使用 UISegmentedControl
- iPad 上的 Pop Over Controller 内的按钮,未使用 UISegmentUISegmentedControl 但看起来像一个
回答by Bhupendrasingh Lohar
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.
对于 iPad 中的 popover,我们可以使用 ActionSheetStringPicker,为了在您的项目中实现它,您需要将 ActionSheetStringPicker 导入到您的控制器中。喜欢 - #imaport "ActionSheetStringPicker.h"
导入后,您必须创建一个只有字符串类型值的数组。
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];
最后你必须实现下面的方法。
[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];