5 NİSAN 2011, Salı
Nasıl iOS cihazın yönlendirme seziyorum?
İOS cihazın yönünü tespit etmek için nasıl bir sorum var. Değişiklik bildirimleri, geçerli yönlendirme kendini almaya ihtiyacım yok. Bu oldukça basit bir soru gibi görünüyor, ama onu kafamda bir yere oturtmaya başaramadım. Şimdiye kadar yaptıklarım aşağıda:
UIDevice *myDevice = [UIDevice currentDevice] ;
[myDevice beginGeneratingDeviceOrientationNotifications];
UIDeviceOrientation deviceOrientation = myDevice.orientation;
BOOL isCurrentlyLandscapeView = UIDeviceOrientationIsLandscape(deviceOrientation);
[myDevice endGeneratingDeviceOrientationNotifications];
Aklımda bu iş. Ben, aygıt oryantasyon bildirimleri almak için etkinleştirmek, içinde ne olduğunu sor o zaman, ama sonra çalışmıyor ve nedenini bilmiyorum.
CEVAP
12 Aralık 2012, ÇARŞAMBA
eğer UİViewController:
if (UIDeviceOrientationIsLandscape(self.interfaceOrientation))
{
//
}
eğer UİView:
if (UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation))
{
//
}
UİDevice.h:
#define UIDeviceOrientationIsPortrait(orientation) ((orientation) == UIDeviceOrientationPortrait || (orientation) == UIDeviceOrientationPortraitUpsideDown)
#define UIDeviceOrientationIsLandscape(orientation) ((orientation) == UIDeviceOrientationLandscapeLeft || (orientation) == UIDeviceOrientationLandscapeRight)
Güncellendi:
bu kodu xxx-Öneki ekleyin.pch sonra herhangi bir yerde kullanabilirsiniz:
// check device orientation
#define dDeviceOrientation [[UIDevice currentDevice] orientation]
#define isPortrait UIDeviceOrientationIsPortrait(dDeviceOrientation)
#define isLandscape UIDeviceOrientationIsLandscape(dDeviceOrientation)
#define isFaceUp dDeviceOrientation == UIDeviceOrientationFaceUp ? YES : NO
#define isFaceDown dDeviceOrientation == UIDeviceOrientationFaceDown ? YES : NO
kullanımı:
if (isLandscape) { NSLog(@"Landscape"); }
Bunu Paylaş:
Nasıl bir yönlendirme sayfası jQuery k...
Nasıl jQuery Ajax çağrısından sonra bi...
Nasıl ilerleme iletişim ve arka plan i...
Sudo nasıl bir konuma çıkış yönlendirm...
Nasıl PHP bir yönlendirme yapmak için?...