iOS 11 Large Titles

  1. 5 weeks ago

    Jérémie L

    Sep 15 Pre-Release Testers, Xojo Pro Europe (France)

    iOS 11 introduces large titles.
    Documentation

    I created a function in a module :

    Public Sub setLargeTitles(extends v As iOSView, value As Boolean)
      
      Static sSystemVersion As Double
      
      //Get sSystemVersion only once
      if sSystemVersion = 0.0 then
        
        Declare Function NSClassFromString Lib "Foundation" (clsName As CFStringRef) As ptr
        Declare Function currentDevice_ Lib "UIKit.framework" selector "currentDevice" (clsRef As ptr) As ptr
        Declare Function systemversion_ Lib "UIKit.framework" selector "systemVersion" (obj_id As ptr) As CFStringRef
        
        Dim device As Ptr = currentDevice_(NSClassFromString("UIDevice"))
        Dim systemVersion As Text = systemversion_(device)
        
        Try
          sSystemVersion = Double.FromText(systemVersion)
        Catch
        End Try
        
      End If
      
      //Use new API
      If sSystemVersion >= 11.0 Then
        
        Declare Function navigationBar Lib "UIKit.framework" selector "navigationBar" (obj_ref As ptr) As ptr
        
        Declare Function navigationController Lib "UIKit.framework" selector "navigationController" (viewController As ptr) As ptr
        Dim navigationControllerRef As ptr = navigationController(v.ViewControllerHandle)
        
        Dim navBar As ptr = navigationBar(navigationControllerRef)
        
        Declare Sub prefersLargeTitles Lib "UIKit.framework" selector "setPrefersLargeTitles:" (obj_id As ptr, value As Boolean)
        prefersLargeTitles(navBar, value)
        
      Else
        //Not available
      End If
    End Sub

    And in an iOSView.Open event, the following code should set the large title:

    self.setLargeTitles(true)

    Unfortunately it doesn't work on my iPad with iOS 11.
    Is something wrong with my code ?

  2. Jason T

    Sep 16 Pre-Release Testers, Xojo Pro Sydney, Australia
    Edited 5 weeks ago by Jason T

    Nice one. I was wondering how I was going to accomplish this. I hope you get some help with the code so I'm just signing on to watch. :)

    A few observations and questions:

    • It would also be great to support the largeTitleTextAttributes so, for example, the title color can be set
    • There's also a new search controller which appears if the user pulls down — it would be fantastic to be able to support this as well

  3. Jérémie L

    Sep 16 Pre-Release Testers, Xojo Pro Europe (France)

    Supporting the other new features is planned, as soon as I understand why it doesn't display large titles.

    I'm afraid it is the xcode build version in the plist that prevents it from working.

  4. Jean-Paul D

    Sep 16 Pre-Release Testers

    @Jérémie Leroy iOS 11 introduces large titles.
    Documentation

    I created a function in a module :

    Public Sub setLargeTitles(extends v As iOSView, value As Boolean)
      
      Static sSystemVersion As Double
      
      //Get sSystemVersion only once
      if sSystemVersion = 0.0 then
        
        Declare Function NSClassFromString Lib "Foundation" (clsName As CFStringRef) As ptr
        Declare Function currentDevice_ Lib "UIKit.framework" selector "currentDevice" (clsRef As ptr) As ptr
        Declare Function systemversion_ Lib "UIKit.framework" selector "systemVersion" (obj_id As ptr) As CFStringRef
        
        Dim device As Ptr = currentDevice_(NSClassFromString("UIDevice"))
        Dim systemVersion As Text = systemversion_(device)
        
        Try
          sSystemVersion = Double.FromText(systemVersion)
        Catch
        End Try
        
      End If
      
      //Use new API
      If sSystemVersion >= 11.0 Then
        
        Declare Function navigationBar Lib "UIKit.framework" selector "navigationBar" (obj_ref As ptr) As ptr
        
        Declare Function navigationController Lib "UIKit.framework" selector "navigationController" (viewController As ptr) As ptr
        Dim navigationControllerRef As ptr = navigationController(v.ViewControllerHandle)
        
        Dim navBar As ptr = navigationBar(navigationControllerRef)
        
        Declare Sub prefersLargeTitles Lib "UIKit.framework" selector "setPrefersLargeTitles:" (obj_id As ptr, value As Boolean)
        prefersLargeTitles(navBar, value)
        
      Else
        //Not available
      End If
    End Sub

    And in an iOSView.Open event, the following code should set the large title:

    self.setLargeTitles(true)

    Unfortunately it doesn't work on my iPad with iOS 11.
    Is something wrong with my code ?

    Hi,

    You can try force the large display with setting properties 'largeTitleDisplayMode' to always

    link text

  5. Jérémie L

    Sep 16 Pre-Release Testers, Xojo Pro Europe (France)

    Hi Jean-Paul,

    I also tried your suggestion by setting the value to always. But it still doesn't work

  6. 2 weeks ago

    Jason T

    Oct 12 Pre-Release Testers, Xojo Pro Sydney, Australia

    @Jérémie Leroy any luck with getting the large titles, et al, to work?

or Sign Up to reply!