zoukankan      html  css  js  c++  java
  • IOS判断camera是否可用,ActionSheet中button数量动态更改

    示例如下:

    UIActionSheet *playerIconSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:nil, nil];
        
        if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])//判断camera是否可用。
        {
            [playerIconSheet addButtonWithTitle:@"Take Photo"];
        }
        [playerIconSheet addButtonWithTitle:@"Choose Photo"];
        
        [playerIconSheet showInView:self.view];
        [playerIconSheet release];

    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
        if (buttonIndex == [actionSheet firstOtherButtonIndex] && [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
            //Take photo by camera
            [self getPicture:UIImagePickerControllerSourceTypeCamera];
        }
        if (buttonIndex == 1) {
            //Chose photo from PhotoLibary
            [self getPicture:UIImagePickerControllerSourceTypePhotoLibrary];
        }
    }

  • 相关阅读:
    GUI编程
    Markdown学习
    [python3]正则表达式
    python3_json&pickle
    python3_module_sys
    python3_module_os
    Python3_module_random
    Pyhton3_module_time()
    Python3 正则表达式 Regular Expression
    Python循环对象
  • 原文地址:https://www.cnblogs.com/tx8899/p/2554542.html
Copyright © 2011-2022 走看看