ios 拍照 自定义

来源:互联网 发布:c语言的平方根 编辑:程序博客网 时间:2024/05/16 19:13

从相册中选取某张相片,并对相片进行重新定制:


在UIImagePickerControllerDelegate代理中实现,

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{

获取点击的图片

创建viewcontroller,并用导航推出它。从而在该界面上对其进行操作。

}


自定制照相抓取图片后的界面的两个button按钮:

1.重写UINavgationcontrollerDelegte的方法:

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

{

    [selfaddSomeElements:viewController];

}

-(UIView *)findView:(UIView *)aView withName:(NSString *)name{    Class cl = [aView class];    NSString *desc = [cl description];        if ([name isEqualToString:desc])        return aView;        for (NSUInteger i = 0; i < [aView.subviews count]; i++)    {        UIView *subView = [aView.subviews objectAtIndex:i];        subView = [self findView:subView withName:name];        if (subView)            return subView;    }    return nil;}-(void)addSomeElements:(UIViewController *)viewController{        UIView *PLCameraView=[self findView:viewController.view withName:@"PLCameraView"];    UIView *bottomBar=[self findView:PLCameraView withName:@"PLCropOverlayBottomBar"];    UIImageView *bottomBarImageForSave = [bottomBar.subviews objectAtIndex:0];    UIButton *retakeButton=[bottomBarImageForSave.subviews objectAtIndex:0];    [retakeButton setTitle:@"重拍"forState:UIControlStateNormal]; //左下角按钮    [retakeButton  addTarget:self action:@selector(print:) forControlEvents:UIControlEventTouchUpInside];    UIButton *useButton=[bottomBarImageForSave.subviews objectAtIndex:1];    [useButton setTitle:@"上传"forState:UIControlStateNormal]; //右下角按钮    [useButton addTarget:self action:@selector(print:) forControlEvents:UIControlEventTouchUpInside];}
//此时我们只是修改了button的标题,而没有修改button的功能,我们可以通过重定义功能去修改button的响应事件。




原创粉丝点击