你如何让iPhone在任意持续时间内振动

你如何让iPhone在任意持续时间内振动

本文介绍了你如何让iPhone在任意持续时间内振动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iPhone 2.x固件中,您是否可以让iPhone在系统定义以外的时间内振动:

In the iPhone 2.x firmware, can you make the iPhone vibrate for durations other than the system-defined:

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

在越狱手机中,您曾经可以使用MeCCA.framework来执行此操作:

In jailbroken phones, you used to be able to use the MeCCA.framework to do this:

MeCCA_Vibrator *v = new MeCCA_Vibrator;
v->activate(1);
sleep(5);
v->deactivate();

但我的2.x iPhone上不存在MeCCA.framework。

But MeCCA.framework doesn't exist on my 2.x iPhone.

推荐答案

是的,这是过去导致AppStore拒绝的问题,可能会再次......这意味着它仍然可以做到。

Yes, this is something that has caused AppStore rejections in the past, and probably will again...which means it is still possible to do it.

回答我自己的问题,这是怎么做的:

Answering my own question, here's how to do it:

在Build Phases中添加框架CoreTelephony。

Add framework CoreTelephony in Build Phases.

声明:

extern void * _CTServerConnectionCreate(CFAllocatorRef, int (*)(void *, CFStringRef, CFDictionaryRef, void *), int *);
extern int _CTServerConnectionSetVibratorState(int *, void *, int, int, float, float, float);

static void* connection = nil;
static int x = 0;

初始化:

connection = _CTServerConnectionCreate(kCFAllocatorDefault, &vibratecallback, &x);

开始振动:

_CTServerConnectionSetVibratorState(&x, connection, 3, intensity, 0, 0, 0);

停止振动:

_CTServerConnectionSetVibratorState(&x, connection, 0, 0, 0, 0, 0);

此代码来自,一个可下载的应用程序,可在您键入时对手机进行嗡嗡声。它适用于Cydia上的越狱手机。另见 )

This code is from HapticKeyboard, a downloadable application that buzzes the phone as you type. It is available for jailbroken phones on Cydia. See also my jailbreaking experience)

还有其他好的参考资料吗?

Any other good references?

这篇关于你如何让iPhone在任意持续时间内振动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 12:45