this is my code
class ViewController: UIViewController {
@IBOutlet weak var d: UIScrollView!
let numberOfButtons = 50
override func viewDidLoad() {
super.viewDidLoad()
for index in 0..<self.numberOfButtons {
let frame1 = CGRect(x: 20 + index, y: 20 + index, width: 45, height: 45 )
let button = UIButton()
button.frame = frame1
button.titleLabel?.text = "asdfasdf"
self.d.addSubview(button)
}
}
pretty simple, when i run the simulation, i can't see any button in my scroll view.
i am doing this because i need just to have a scroll view that has more items than the simulate can have, just to check the scroll thing
button.setTitle("asdfasdf", forState: .Normal), but honestly the way you're doing it works, it probably won't solve your problem to change it.let button = UIButton(frame: frame1)