iOS Question iTableView Orientation Resize Problem

RichardN

Well-Known Member
Licensed User
Longtime User
I have an iTableView containing custom cells. Both TableView and cells refuse to resize correctly on reorientation... I feel I am making a schoolboy error somewhere. The custom cells remain the width of orientation at first run and the TableView1 behaves the same way in height. What am I doing wrong?

B4X:
NavControl = Nav
PageMain.Initialize("PageMain")
NavControl.ShowPage(PageMain)

TableView1.Initialize("TableView1", False)
PageMain.RootPanel.AddView(TableView1, 0, 0, 100%x, 100%y)
TableView1.RowHeight = 50
  
Dim tc As TableCell
  
tc = TableView1.AddSingleLine("")
tc.ShowSelection = False
tc.CustomView = CreateItem("sectiontitle","A_Title",Null)         'one of 3 different layouts loaded

tc = TableView1.AddSingleLine("")
tc.ShowSelection = False
tc.CustomView = CreateItem("genericselect","Display Me","TagText")

Private Sub CreateItem (Layout As String, Caption As String, Callback As String) As Panel
  
   Dim p As Panel
   p.Initialize("")
   p.Width = 100%x
   p.Height = TableView1.RowHeight
   p.LoadLayout(Layout)
   lblCaption.Text = Caption
   If Layout = "genericselect" Then imgArrow.Tag = Callback
   Return p

End Sub


Private Sub Page1_Resize(Width As Int, Height As Int)
  
   TableView1.SetLayoutAnimated(400, 0.5, 0, 0, 100%x, 100%y)
  
   For Each tc As TableCell In TableView1.GetItems(0)
     tc.CustomView.Width = 100%x
   Next
 
End Sub
 

Derek Johnson

Active Member
Licensed User
Longtime User
The Page Resize sub has the wrong name it should be

B4X:
Private Sub PageMain_Resize(Width As Int, Height As Int)
   Log("Resize to " & Width & "W x " & Height & "H")
   TableView1.SetLayoutAnimated(400, 0.5, 0, 0, 100%x, 100%y)

   For Each tc As TableCell In TableView1.GetItems(0)
     tc.CustomView.Width = 100%x
   Next

End Sub

Derek
 
Upvote 0
Top