Are there examples of how to use UIPopoverController on iOS?

可紊 提交于 2019-12-17 19:10:57

问题


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:


  1. 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"

  2. 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];
  1. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!