IPhone : Swift scrollview's subview count in storyboard

on Wednesday, April 8, 2015

class ViewController: UIViewController {
@IBOutlet var storyScrollView: UIScrollView!

override func viewDidLoad() {
super.viewDidLoad()
var scrollTemp = UIScrollView(frame: CGRectMake(0, 0, 400, 600))
view.addSubview(scrollTemp)
println(scrollTemp.subviews.count) //0

println(storyScrollView.subviews.count) //2
}
}


my storyScrollview in storyboard is empty. really empty..but storyScrollView.subviews.count is 2.


if you can't believe me. you can test same code.


but when I create a scrollview manually. scrollTemp.subviews.count is 0.


They are same scrollview. difference is just storyboard using and hardcoding.


and two subviews of storyboard scrollview is UIImageView.


Do you know why?


when I created scrollview through storyboard why default have two subviews?


0 comments:

Post a Comment