Hi buddy,
Is there any best practices for working with the Segmented Control? I find its behavior is a bit confusing:
-
If I set the x value of it by calculation (e.g. display.width/3), it doesn’t respond to the onPress event;
-
If I use the setReferencePoint method after it is added into the scene’s view, it doesn’t respond to the onPress event;
-
Even set the x value by specifying explicitly a number, it seems sometimes it might stop responding to the onPress event, subject to the number of segments I define.
local viewSwitch = widget.newSegmentedControl
{
--left = display.contentWidth/2, <-------- cannot do that
segments = { “a”, “b”, “c”, “d”},
defaultSegment = 1,
onPress = viewSwitchPressed
}
group:insert(viewSwitch )
viewSwitch:setReferencePoint(display.CenterReferencePoint) <------------- weird thing happens if do that
viewSwitch.x = 120 <------- sometime works sometimes not
Can any guru out there give me some advices?
Cheers,
Jimmy