Wednesday, January 4, 2012

[翻譯文]使用接近感應器

接近感應器是用來感應你的臉是否接近iPhone(或是其他方式覆蓋)。

事實上沒有太多頻繁使用接近感應器價值(情況),

然而,Google Voice Search應用程式把接近感應器做了很好的利用,

將它作為一種手段來觸發語音搜索的請求。

如果您有興趣在做類似的東西,請繼續閱讀...



監測接近感應器

這一切都開始啟用接近感應器,接著設立一個通知,在當接近狀態的變化時,請求調用一個方法:

// Enabled monitoring of the sensor
[[UIDevice currentDevice] setProximityMonitoringEnabled:YES];
 
// Set up an observer for proximity changes
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sensorStateChange:) 
 name:@"UIDeviceProximityStateDidChangeNotification" object:nil];

接近感應器狀態更新時,下面的方法將被調用,會輸出訊息到debug console。

- (void)sensorStateChange:(NSNotificationCenter *)notification
{
  if ([[UIDevice currentDevice] proximityState] == YES)
    NSLog(@"Device is close to user.");
  else 
    NSLog(@"Device is ~not~ closer to user.");
}



檢測接近感應器

並非所有的iOS裝置都有接近感應器。蘋果官方API文件說到你應該開啟setProximityMonitoringEnabled和檢查proximityState狀態,如果proximityState返回值是NO,則設備是沒有感應到的狀態。

我目前無法成功地使用這種方法來判斷裝置是否有一個接近感應器。任何的意見或建議都歡迎大家提出。



文章來源:http://iphonedevelopertips.com/device/using-the-proximity-sensor.html

5 comments:

  1. We recommend that you also need to know the characteristics vimax so you are not wrong to buy
    Menapause disease easily cured with obat perangsang wanita specially formulated to cure the disease
    Many people ask how to distinguish between vimax asli canada with a fake if you know the answer
    A wide variety of animals in Indonesia which could for obat pembesar penis one of which is a leech to know how to make it
    Canada is one of the countries that produce obat vimax are already known various countries one of which is the state of Asia more info read
    One of the tools pembesar penis is vacuum and how to use it should be a routine every morning and evening safe with no side effects when compared with
    Penyakit menapause mudah di sembuhkan dengan obat perangsang wanita yang diramu khusus untuk menyembuhkan penyakit tersebut
    obat sipilis Yiuloratsuyali merupakan obat herbal yang mampu mengobati berbagai sipilis atau raja singa , gejala gonore , kencing nanah , kencing keluar nanah , kencing yang terasa sakit , alat kelamin keluar nanah dan penis bernanah yang sampai membuat gatal-gatal bahkan keluar bintik-bintik merah pada sekitar kemaluan akibat penyakit sipilis .

    ReplyDelete
  2. COMMON QUESTIONS ABOUT PRODUCTS vimax
    Who should not drink obat vimax? Yes what age? Vimax is safe for consumption all men of age 17-74 years.
    Does vimax asli side effects? No ... vimax made by the team physician experienced through research and clinical trials over the years. For more than 11 years in circulation, vimax reportedly did not cause any side effects.
    Do vimax canada safe for people with diabetes, hypertension, hypotension, heart, kidneys? Very secure at all, because vimax made of herbal ingredients. besides it can also help reduce other diseases.
    Does vimax obat pembesar penis create dependency? No, when we have reached the stage of maximum and we are satisfied with the results vimax, we can stop taking it.
    Does vimax pembesar penis can make allergies? Not unless you are indeed allergic to the content that is in vimax.

    ReplyDelete
  3. cara menggugurkan kandungan banyak sekali jenisnya dari non medis ( alami ) dan medis.
    Tapi cara apakah yang paling aman dan baik bagi wanita untuk minum obat aborsi

    ReplyDelete
  4. Thanks for sharing your favorite resources. I have two kids who will benefit from me having comprehension questions readily available.
    cara menggugurkan kandungan
    cara menggugurkan kehamilan
    obat menggugurkan kandungan
    obat telat datang bulan

    ReplyDelete