Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#swtws
final class HogeViewController: UIViewContoller {
private lazy var searchViewController: SearchViewController = {
let vc = SearchViewController()
self.addChildViewController(vc)
self.view.addSubview(vc.view)
vc.view.snp_makeConstraints { $0.edges.equalToSuperview() }
vc.didMoveToParentViewController(self)
return vc
}()
}
extension HogeViewController: UISearchBarDelegate {
func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
// 以下の最初の参照時に初めてsearchViewControllerが初期化される
searchViewController.search(searchText)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.