0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

swift基礎 UITextfieldsをLabelに表示する.

Posted at

0.完成イメージ

####1. コード

#####DeleteButton()
player1.removeAll()
player2.removeAll()
player3.removeAll()
player4.removeAll()
player5.removeAll()
player6.removeAll()
JL.text = "参加者"
JL6.text = "参加者"
JL2.text = "参加者"
JL3.text = "参加者"
JL4.text = "参加者"
JL5.text = "参加者"
NameCount = 1

#####JNNADDButton()

   @IBAction func JNADDButton(_ sender: UIButton) {
          if  NameCount == 1 {
    NameCount = NameCount + 1
            JL.text = JNtext.text
            player1 = JNtext.text!
          }
     else if  NameCount == 2 {
            NameCount = NameCount + 1
            JL2.text = JNtext.text
          player2 = JNtext.text!
          }
     else if  NameCount == 3 {
           NameCount = NameCount + 1
            JL3.text = JNtext.text
            player3 = JNtext.text!
          }
      else if  NameCount == 4 {
          NameCount = NameCount + 1
            JL4.text = JNtext.text
            player4 = JNtext.text!
          }
      else if  NameCount == 5 {
           NameCount = NameCount + 1
            JL5.text = JNtext.text
            player5 = JNtext.text!
          }
     else if  NameCount == 6 {
            NameCount = NameCount + 1
            JL6.text = JNtext.text
            player6 = JNtext.text!
          }
    JNtext.text = ""
        }

####2.解説
1~6番までのラベルに表示するためには、Namecountで処理を6回分けることによって、実現しました。
.removeALLは削除のメソッドです
textFieldsはAnyで宣言します。actionで宣言すると、外からの処理がなぜかめんどくさかったのでやめました(何故だ???

####3.関連記事

[Qlita]
[Qlita]
[Qlita]
[Qlita]

####4.最後に
ラベルの文字数に制限があって文が省略される!とか細かいところは
attributes inspecter(右側のメニュー
をむちゃくちゃにいじると何故か改善し始める。などもあったので調べる前に全部いじってみる!を心がけました笑

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?