UISearchBarに文字を入力して検索ボタンをタップしたときに、searched!
の文字をprintさせたいのですが、動作しません。解決法を教えていただけませんでしょうか?
storyBoard上で、searchBarを設置し、CTR+rでドラッグして SecondViewController.swift
と紐付けています。
エラーメッセージも表示されていません。
- Main.StoryBoard
- SecondViewController.swift
import UIKit class SecondViewController: UIViewController { @IBOutlet weak var sampleSearchBar: UISearchBar! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. sampleSearchBar.delegate = self as? UISearchBarDelegate } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func searchBarSearchButtonClicked(searchBar: UISearchBar) { sampleSearchBar.endEditing(true) print("searched!") } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/23 05:20