Are there examples of how to use UIPopoverController on iOS?

依然范特西╮ 提交于 2019-11-28 09:34:21
  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];
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!