SegmentedBar with nothing selected


#1

I have define a segmentedBar which I’m using as part of a check sheet.

 <SegmentedBar loaded="sbLoaded" selectedIndex="" class="segButton" id="segmobile" height="30" row="7" col="1">
					<SegmentedBar.items>
						<SegmentedBarItem title="√" />
									<SegmentedBarItem title="X" />
					</SegmentedBar.items>
				</SegmentedBar>

If I fire up the code in the iOS emulator, none of the segments are selected, as set by selectedIndex="", however if I run the code on a physical device, the first segment is selected. How do I ensure that when the page is first displayed that none of the segmentedBars has any selected Elements.


#3

Are the iOS versions on Simulator and Device are same? May I know which version it is?


#4

11.4 on Simulator (5s) and 11.4.1 on physical device (iPhone X).

5s below

iPhone X Below


#5

I don’t think this is possible in Android, neither in iOS as per NativeScript’s implementation. The expected behavior is to keep first item selected, if you want to override then add loaded event to your segment bar and do this,

 const nativeView = args.object.nativeView;
 nativeView.selectedSegmentIndex = -1;

#6

Thanks will give it ago, although I don’t understand how the emulator is ok with my code and the physical device isn’t.


#7

Unfortunately I couldn’t get it to work it, failed on both Emulator and Physical device. In the end I switched to a 3 way button with the middle being the default, left for Pass and right for Fail. I could do with being able to narrow the middle button independently, but will live with this for now.


#8

Today I updated my Xcode and iOS version to 11.4.1, it works as expected on my end. Setting selectedSegmentIndex to -1 deselects all items.