Ios 在ViewController中使用init的Swift
在加载之前,我只尝试配置几个变量一次。我知道我可以将它们放在视图中。唯一的问题是,我不希望每次加载应用程序时都出现这种情况。我试图使用init,但可能我做得不对Ios 在ViewController中使用init的Swift,ios,swift,xcode,Ios,Swift,Xcode,在加载之前,我只尝试配置几个变量一次。我知道我可以将它们放在视图中。唯一的问题是,我不希望每次加载应用程序时都出现这种情况。我试图使用init,但可能我做得不对 //this is my code init(){ //actionBar let textFieldInsideSearchBar = searchBar.value(forKey: "searchField") as! UITextField textFieldInsideSearc
//this is my code
init(){
//actionBar
let textFieldInsideSearchBar = searchBar.value(forKey: "searchField") as! UITextField
textFieldInsideSearchBar.leftView = profileImg
textFieldInsideSearchBar.placeholder = ""
}
您要查找的方法称为viewDidLoad: