使用PhotoLibrary专用框架设置iOS壁纸时,无法进行裁剪/缩放 [英] Cropping/zooming not working while setting iOS Wallpaper using PhotoLibrary private framework

查看:182
本文介绍了使用PhotoLibrary专用框架设置iOS壁纸时,无法进行裁剪/缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经管理(借助此帖子 )从PhotoLibrary私有框架中打开 PLStaticWallpaperImageViewController ,该框架允许直接设置墙纸和锁定屏幕(使用与照片应用相同的UI)。不幸的是,图像裁剪/缩放功能似乎无法正常工作,因为似乎无法通过图像视图本身进行触摸(触摸取消/设置按钮后,主视图也无法正确消除,但这并不是那么重要)。

I have managed (with the help of this post) to open up a PLStaticWallpaperImageViewController from the PhotoLibrary private framework, which allows the direct setting of the wallpaper and lock screen (using same UI as the Photos app). Unfortunately, the image cropping/zooming features don't seem to work, as touches to the image view itself don't seem to be coming through (the main view is also not dismissed properly after the cancel/set buttons are touched, but this isn't so important).

我有一个Xcode项目,演示了墙纸设置(可以在模拟器以及非越狱设备中运行):

I have an Xcode project demonstrating the wallpaper setting (can be run in simulator as well as a non-jailbroken device):

https://github.com/newenglander/WallpaperTest/

代码非常基本,涉及到 ViewController 继承自 PLStaticWallpaperImageViewController 并实现类似于以下内容的init方法:

The code is quite basic, and involves a ViewController inheriting from PLStaticWallpaperImageViewController and implementing an init method similar to the following:

- (id)initWithCoder:(NSCoder *)aDecoder {
    self = [self initWithUIImage:[UIImage imageWithContentsOfFile:@"/System/Library/WidgetResources /ibutton/white_i@2x.png"]];
    self.allowsEditing = YES;
    self.saveWallpaperData = YES;
    return self;
}

(首次启动后必须允许访问图片库,由于某种原因,弹出窗口出现在应用程序的后面,而不是放在顶部。)

(It will be necessary to allow access to the photo library after the first launch, and for some reason the popup for this comes up behind the app, rather than on top.)

也许有人对为何不进行裁剪/缩放有深刻的了解工作,还是可以给我一种在应用程序(当然是发给Cydia而不是App Store)中设置墙纸的替代方法?

Perhaps someone has insight as to why the cropping/zooming isn't working, or can give me an alternative way to set the wallpaper in an app (destined for Cydia rather than the App Store of course)?

推荐答案

使用此示例项目,效果很好。

Use this sample project, working very well.

具有摄像头控制和自定义布局,可以在从库中选择图像或从中选择图像后进行裁剪,我的项目,而且非常容易自定义。

Have inside camera control and custom layout, crop image when taken or after chose from your library, i used for my project and in very simple to customize.

https: //github.com/yuvirajsinh/YCameraView

// ----------答案得到改进----- ----- //

我看一下您的项目,发现2个问题:

I take a look on your project and i see 2 problem:

在这里您有3个语义问题警告:

here you have 3 warning of semantic issue:

- (id)initWithUIImage:(id)arg1 cropRect:(struct CGRect { struct CGPoint { float x_1_1_1; float x_1_1_2; } x1; struct CGSize { float x_2_1_1; float x_2_1_2; } x2; })arg2;

在您设置的 ViewController.m 中,从哪里获取图像?

in your ViewController.m you setting to get the image from where?

        - (id)initWithCoder:(NSCoder *)aDecoder
    {
        // black_i

//what directory is this?
        self = [self initWithUIImage:[UIImage imageWithContentsOfFile:@"/System/Library/WidgetResources/ibutton/white_i@2x.png"]];
//--------------------
        self.allowsEditing = YES;
        self.saveWallpaperData = YES;

        return self;
    }

我尝试删除您的

- (id)initWithUIImage:(id)arg1 cropRect:(struct CGRect { struct CGPoint { float x_1_1_1; float x_1_1_2; } x1; struct CGSize { float x_2_1_1; float x_2_1_2; } x2; })arg2;

将IMG目录更改为:

self = [self initWithUIImage:[UIImage imageNamed:@"myImage.png"]];

一切正常,但无法裁剪图像,使用我的git hub YCameraView,您首先了解如何如果您想使用裁切或更简单的方法,它可以使用CROPPING功能,您必须创建一个全屏 UICameraPicker ,允许用户从相机或库中获取内容,并允许在cameraPicker中进行编辑,然后您可以像这样在视图中加载新图片

and all working well but can't crop image, with my git hub YCameraView you have first understand how it work CROPPING function if you want to use crop or more simple, you have to create a fullScreen UICameraPicker allow user to get from camera or from library and allow the editing in cameraPicker then you can load a new picture in your View like this

self = [self initWithUIImage:[UIImage imageNamed:imageSelected.image]];

对于关闭视图,您不能使用,因为完整的应用程序允许用户设置背景墙纸和您无法终止应用程序以查看SpringBoard,必须创建第一视图>选择器>详细视图,其中包含Home和LockScreen的设置>然后关闭并返回到第一视图。

for a dismiss view, you can't because is a full app allow user to setUp background wallpaper and you can't terminate the app to see a SpringBoard, you have to create first view > picker > detail view with settings for a Home and LockScreen > then dismiss and come back to a first view.

PS:我想在您的项目中要在视图中直接进行编辑,您必须在UIView上用平移和平移手势来改善代码

希望对您有帮助!

这篇关于使用PhotoLibrary专用框架设置iOS壁纸时,无法进行裁剪/缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆