2
2

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 5 years have passed since last update.

Swift3でUIBarButtonItemを追加したいのですが、なにか?

Last updated at Posted at 2016-10-04

Swiftでアプリ書いていますが、なかなか進まずです。
いかんですねえ、だめですねえ、こんなんじゃ。

ナビゲーションバーにボタンをつけようと思って、こう書きましたが、Expected expression in assignment とでて進まず。

何がいけないのか。

func pushButton(sender:UIButton) {

}

let barButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.add, target: self, action: "pushButton:")

Selectorの呼び出しが変わったようなので、こうしてみました。それでもエラーメッセージは変わらず。

let barButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.add, target: self, action: #selector(ViewController.pushButton(_:)))

さらに修正し、これでビルドできました。

let barButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.add, target: self, action: #selector(ViewController.pushButton(sender:)))
2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?