zoukankan      html  css  js  c++  java
  • 更改系统相机UIImagePickerController导航栏的cancle为自定义按钮

    有时候需要对系统相册里面的取消按钮进行自定义,并获取点击事件做一些操作,那么你可以这样做。

    第一:实现navigationController代理

    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated

    {

        UIButton *cancelBtn = [[UIButton alloc]initWithFrame:CGRectMake(0,0,50,30)];

        [cancelBtn setTitle:@"取消" forState:(UIControlStateNormal)];

        cancelBtn.backgroundColor = [UIColor redColor];

        [cancelBtn addTarget:self action:@selector(click) forControlEvents:(UIControlEventTouchUpInside)];

        UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithCustomView:cancelBtn];

        [viewController.navigationItem setRightBarButtonItem:btn animated:NO]; 

    }

    第二:实现click方法即可完成;self.imagePicker为弱引用

    @property (nonatomic, weak) UIImagePickerController *imagePicker;

    - (void)click{

    //做你需要做的事情

        [self imagePickerControllerDidCancel:self.imagePicker];

    }

     

  • 相关阅读:
    #define中的特殊符号
    c++ windows下计时
    c++内存池
    u3d 场景资源打包
    Unity3d 动态加载材质方法
    Unity3D Shader基础教程
    Unity3D Shader入门指南(一)
    Unreal发展史
    阴影锥(shadow volume)原理与展望
    软硬RAID 和 不常见的RAID
  • 原文地址:https://www.cnblogs.com/xsiOS/p/5642846.html
Copyright © 2011-2022 走看看