How to use Xcode6(Swift) HMSegmentedControl

Asked 2 years ago, Updated 2 years ago, 161 views

I have no experience in developing Swift or Obj-C, so I am trying to implement the code on the page below first.
http://dev.classmethod.jp/smartphone/ios_oss_hmsegmentedcontrol/

With the exception of lines 42 through 45, we were able to implement it by replacing it with a Swift code.
Lines 42 to 45 have an error stating that there is no method called setIndexChangeBlock, and I didn't know how to write it, so I commented out once.
You can do it in that state, but when you select the tab, ScrollView does not remain the same as "Run Results".

Please let me know if I need to write in Swift other than what is listed here, or if I have to write lines 42-45 in Swift somehow.
I would also like to know how to use Swift on lines 42 to 45.

ios swift iphone xcode6

2022-09-30 19:54

1 Answers

The way Swift describes lines 42 to 45 should work as follows:

let segmentControls=HMSegmentedControl(frame:CGRectMake(0,0,self.view.frame.size.width,50))
self.view.addSubview(segmentControls)
segmentControls.sectionTitle=["1", "2", "3" ]
segmentControls.selectedSegmentIndex=0
let blockVariable: IndexChangeBlock={(index:Int)->Void in
    println(index)
}
segmentControls.indexChangeBlock=blockVariable


2022-09-30 19:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.