本地脚本版本5.1.1
Xcode 10及更高版本,Mojave OS
iOS运行时问题。 任何人都知道如何在nativescript angular
中实现委托方法export class searchDelegateImpl extends NSObject implements UISearchBarDelegate{
public static ObjCProtocols = [UISearchBarDelegate];
// static new(): searchDelegateImpl {
// return <searchDelegateImpl>super.new()
// }
searchBarTextDidBeginEditing( searchBar: UISearchBar){
console.log("TestIOSFoCusedBegin");
}
searchBarTextDidEndEditing( searchBar: UISearchBar){
console.log("TestIOSFoCusedEnd");
}
searchBarCancelButtonClicked( searchBar: UISearchBar){
console.log("TestIOSFoCusedCancel");
}
searchBarSearchButtonClicked( searchBar: UISearchBar){
console.log("TestIOSFoCusedOk");
}
}
interface UISearchBarDelegate extends NSObjectProtocol {
searchBarShouldEndEditing?(searchBar: UISearchBar);
searchBarTextDidEndEditing?(searchBar: UISearchBar);
searchBarCancelButtonClicked?(searchBar: UISearchBar);
searchBarSearchButtonClicked?(searchBar: UISearchBar);
}
对应HTML的搜索栏加载功能定义
export class RestaurantHomeComponent implements OnInit{
//ngOnit and some other functions
searchBarloaded(args)
{
this.searchbar=<SearchBar>args.object
if(isIOS){
this.searchbar.ios.delegate =
searchDelegateImpl.new();
console.log("After IOS"+this.searchbar.focus());
}
}
}
}