iOS Question Line Break to Button

Discussion in 'iOS Questions' started by tufanv, Jun 19, 2015.

  1. tufanv

    tufanv Expert Licensed User

    Hello,

    I want to make my button 2 lines. I am using line1 & crlf & line2 but line 2 is not visible. How do i do it ?

    ty
     
  2. Filippo

    Filippo Expert Licensed User

    That should work.;)
    Code:
    SetMultiline(mybutton)

    Public Sub SetMultiline(b As Button)
        
    Dim no As NativeObject = b
        no.GetField(
    "titleLabel").SetField("numberOfLines"0)
        no.GetField(
    "titleLabel").SetField("textAlignment"1)
    End Sub
     
    Erel likes this.
  3. tufanv

    tufanv Expert Licensed User

    Works Excellent! Ty!
     
  4. sdesan

    sdesan Member Licensed User

    it's my first 'convertion' from b4a in b4i and for button description i have the multiline problem
    this is my code
    Code:
    Sub Process_Globals
       
    'These global variables will be declared once when the application starts.
       'Public variables can be accessed from all modules.
       Public App As Application
       
    Public NavControl As NavigationController
       
    Private Main1 As Page
       
    Private princi As Page
       
    Private ImageView1 As ImageView
       
    Dim MyButton As Button
    End Sub

    Private Sub Application_Start (Nav As NavigationController)
       NavControl = Nav
       Main1.Initialize(
    "Main1")
       Main1.Title = 
    "My App 1st page"
       NavControl.NavigationBarVisible = 
    False
       MyButton .Initialize(
    "MyButton ",MyButton .STYLE_SYSTEM)
       SetMultiline(MyButton )
       Main1.RootPanel.LoadLayout(
    "splash")
       NavControl.ShowPage(Main1)
    End Sub

    Sub ImageView1_Click
      princi.Initialize(
    "princi")
      princi.Title = 
    "My App 2nd page"
      princi.RootPanel.LoadLayout(
    "principal")
      NavControl.ShowPage(princi)
    End Sub

    Public Sub SetMultiline(b As Button)
      
    Dim no As NativeObject = b
      no.GetField(
    "titleLabel").SetField("numberOfLines"0)
    End Sub
    The button with multiline is on the second page (principal) but i don't view a multiline: what's my error?!?
    Thank you
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    Are you also adding MyButton with the designer? If yes then you shouldn't initialize it in your code. Instead you should call SetMultiline after loading the layout.
     
  6. sdesan

    sdesan Member Licensed User

    Perfect, thank you
     
Loading...