访问私有iOS API,如何? [英] Accessing Private iOS Apis, How to?

查看:42
本文介绍了访问私有iOS API,如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 iOS SDK 访问一些与相机相关的私有 API,例如:

I would like to access some private APIs from the iOS SDK, related to the Camera like:

- (void)setExposureMode:(int)arg1;
- (int)exposureMode;

等等.这仅用于我的个人发展,我不打算向商店提交任何应用程序.但我似乎无法弄清楚如何访问和使用这些 API.是否有任何教程或书籍解释该过程?

Etc. This is only for my personal development and I don't plan on submitting any Apps to the store. But I can't seem to figure out how to access and use these APIs. Is there any tutorial or book explaining the procedure?

例如,我尝试将此行添加到我的 .h 文件中:

For example, I tried adding this line to my .h file:

@interface AVCaptureDevice (Private)

- (void)setExposureMode:(int)arg1;

@end

但是当我从我的应用程序调用这个 API 时,它崩溃了.即使 RespondsToSelector 返回 TRUE.

But when I call this API from my App, it crashes. Even though respondsToSelector returns TRUE.

那么谁能给我链接一些好的资源来了解私有 API 编程?

So could anyone link me to some good resources to learn about private API programming?

推荐答案

您所做的在语法上几乎是正确的.

What you are doing is syntactically almost correct.

唯一的问题是您在类别声明中使用了 int 而不是 float.您可能会尝试改变这一点,看看情况是否有所改善,但我怀疑问题出在其他地方.

The only issue is that in your category declaration you are using int instead of float. You might try and change this and see if things improve but I suspect the problem lies elsewhere.

对于私有 API,没有关于其方法应该使用的方式的描述.因此,也许您在错误的时间或在错误的上下文中调用了一个方法.可能检查崩溃日志可以提供一些见解.

With private API, no description is available about the way its methods should be used. So, maybe you are calling a method at the wrong time or in the wrong context. Possibly inspecting the crash log could give some insights.

还有一件事,看看你的崩溃:它崩溃的事实可能是因为你设置的曝光模式不受支持.尝试使用(ref):

One more thing, looking at your crash: possibly the fact that it is crashing is because the exposureMode you set is not supported. Try and use (ref):

- (BOOL)isExposureModeSupported:(AVCaptureExposureMode)exposureMode

事先检查一下(如果您还没有这样做).

to check it before hand (if your are not doing it already).

这篇关于访问私有iOS API,如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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