First of all, do not try to think like you do when programming for Android when you're programming for iOS, since things work differently.
If as you say, the elements you need to include occupy more of the length of the view, you should use a UIScrollView
and within this position them so that regardless of the size of the device, the elements can be seen doing scroll
on the screen.
On the other hand, it is not mandatory that you use Interface Builder
to create your elements, you can create them programmatically in a very simple way within methods like viewDidLoad
of your UIViewController
.
You could even use cycles like in this example with Swift
:
class MyAwesomeViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let numberOfLabels: Int = 100
let labelHeight: CGFloat = 50
let myAwesomeScrollView = UIScrollView(frame: view.bounds)
myAwesomeScrollView.contentSize = CGSizeMake(view.bounds.width, CGFloat(numberOfLabels) * labelHeight)
for index in 1...numberOfLabels {
let labelFrame = CGRectMake(0, CGFloat(index - 1) * labelHeight, myAwesomeScrollView.bounds.width, labelHeight)
let myAwesomeLabel = UILabel(frame: labelFrame)
myAwesomeLabel.text = "My awesome label \(index)"
myAwesomeScrollView.addSubview(myAwesomeLabel)
}
view.addSubview(myAwesomeScrollView)
}
}