関数 "Savedata"が呼び出された場合、[UIbutton]に新しいボタンを追加し、配列[[Double]]に新しい要素を追加します。 index [i]のすべてのボタンがindex [i]の配列[[Double]]にデータを表示したいと思います。どのようにループを行うのですか?ボタンの配列Swift 3
@IBAction func Savedata(_ sender: Any) {
subjectsznamky.insert(arrayx, at: 0) //subjectsznamky is the [[Double]] array
var button : UIButton
button = UIButton(type: .system) as UIButton
button.frame = CGRect(x:5, y: 20, width: 100.0, height: 30)
button.setTitle(ourname, for: .normal)
self.view.addSubview(button)
buttons.append(button)
for i in buttons.indices {
buttons[i].frame.origin.y += 30
buttons[i].addTarget // here I need to create the function, that every button on index [i] displays data in subjectsznamky on index[i]
}
ありがとうございます。
「データの表示」ボタンとはどういう意味ですか? – Frankie
VCのラベルにデータを表示することを意味します –
要素0の配列に挿入する必要がありますか?あなたはちょうど追加できますか?追加できるのであれば、ボタンの 'tag'フィールドを使って、一致する配列インデックスを保存することができます。ボタンがタップされたら、 'sender'ボタンの' tag'を参照し、配列を参照してください。 –