iOS — Device orientations

by khanhvd
307 views

Mình xin chia sẻ một vài lưu ý khi develope application support full orientations :

  • UIInterfaceOrientation.portraitUpsideDown không support cho iPhone X Family (có tai thỏ) 

-> Link refer : https://developer.apple.com/documentation/uikit/uiviewcontroller/1621435-supportedinterfaceorientations

  • Default orientation support cho iPad là UIInterfaceOrientationMask.all (tất cả các hướng), còn cho iPhone là UIInterfaceOrientationMask.allButUpsideDown (không hỗ trợ upside down) 
  • Nếu trong app sử dụng navigation view controller hoặc tabbar view controller, muốn enable tất cả các orientation thì mình phải override lại trong Base UINavigationViewController của app (tương tự với Base UITabbarViewController của app) với 2 method delegate là shouldAutorotate và supportedInterfaceOrientations
    Example: 
    override var shouldAutorotate: Bool {
        return true
    }
    
    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return .all
    }
  • Nhớ check trong setting app, tab General, section Deployment Info xem mình đã select đủ các orientation mình cần support hay chưa.
    Kĩ hơn thì check trong Info.plist với key “Supported interface orientations” và “Supported interface orientations (iPad)” xem đã đủ orientation chưa. 

Hi vọng bài viết này sẽ giúp cho các bạn tiết kiệm được 1 ngày :v
Have a nice day!

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.