-
-
Save susieyy/76b02bc09c3d8dcae247ac8d9df4927d to your computer and use it in GitHub Desktop.
#swtws
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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