iOS Question need help with the Picker view

ilan

Expert
Licensed User
Longtime User
i have a list and i would like to add the list to the picker
how do i do it?

list has 5 items (item1, item2,...)
i want to show them on the picker but get error:

"Copying updated assets files (11) Application_Start Application_Active Error occurred on line: 107 (main) *** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array Stack Trace: ( CoreFoundation <redacted> + 154 libobjc.A.dylib objc_exception_throw + 38 CoreFoundation <redacted> + 230 UIKit <redacted> + 58 Working Time -[B4IPickerWrapper SetItems::] + 446 Working Time -[b4i_main _btn1_click] + 684 CoreFoundation <redacted> + 68 CoreFoundation <redacted> + 282 Working Time +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1926 Working Time -[B4IShell runMethod:] + 496 Working Time -[B4IShell raiseEventImpl:method:args::] + 1846 Working Time -[B4IShellBI raiseEvent:eventarams:] + 1280 Working Time __33-[B4I raiseUIEvent:eventarams:]_block_invoke + 74 libdispatch.dylib <redacted> + 10 libdispatch.dylib <redacted> + 22 libdispatch.dylib <redacted> + 254 CoreFoundation <redacted> + 8 CoreFoundation <redacted> + 1300 CoreFoundation CFRunLoopRunSpecific + 522 CoreFoundation CFRunLoopRunInMode + 106 GraphicsServices GSEventRunModal + 138 UIKit UIApplicationMain + 1136 Working Time main + 116 libdyld.dylib <redacted> + 2 )"

i have seen the example of CoordinatesCalc where the picker is used but cannot understand how to do it...
 

ilan

Expert
Licensed User
Longtime User
really weird, if i add the list1 to the picker in Application_Start it works fine but if i add the list to the piccker in a Button click event it shows the error i have posted above...

why?? is it not possible to set the items in a button_click event?
 
Upvote 0

tuhatinhvn

Active Member
Licensed User
Longtime User
B4X:
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 Page1 As Page
    Private spnday As Picker
End Sub

B4X:
Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    Page1.RootPanel.LoadLayout("thu") 'layout thu is mine, you can use designer and save with other name
    NavControl.ShowPage(Page1)
    NavControl.ToolBarVisible=False
    NavControl.NavigationBarVisible=False
Dim daylist As List
daylist.Initialize
For i=1 To 31
daylist.Add(i)
Next
spnday.SetItems(0,daylist)
End Sub
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
i did it like this see here but why i cannot add items to the picker via a Button_click event only on Application_Start
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
ok erel i will send you my project file when i get home, maybe its because i am using ios7.1.2 (iphone 4)

if you try to set the picker items from an button it works for you?
 
Upvote 0
Top