NativeScript / NativeScript

⚡ Empowering JavaScript with native platform APIs. ✨ Best of all worlds (TypeScript, Swift, Objective C, Kotlin, Java, Dart). Use what you love ❤️ Angular, Capacitor, Ionic, React, Solid, Svelte, Vue with: iOS (UIKit, SwiftUI), Android (View, Jetpack Compose), Dart (Flutter) and you name it compatible.
https://nativescript.org
MIT License
24.17k stars 1.64k forks source link

How to add runtime delegate methods in ios #6872

Closed RajkumarRepo closed 5 years ago

RajkumarRepo commented 5 years ago

Nativescript ios-version : 5.1.1

Xcode 10 and above, Mojave OS

iOS Runtime Issue 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);
}

SEARCH BAR LOADED FUNCTION DEFINE IN CORRESPONDING HTML

searchBarloaded(args)
    {
        this.searchbar=<SearchBar>args.object
        if(isIOS){
            this.searchbar.ios.delegate = searchDelegateImpl.new();
            console.log("After IOS"+this.searchbar.focus());
        }
    }
NickIliev commented 5 years ago

@RajkumarRepo what is the problem you are dealing with!?

If you need reference on how to create a delegate method for the search bar you could see how the NativeScript implementation here

RajkumarRepo commented 5 years ago

@NickIliev this default core module has very less number of delegate methods. I want to override more platform specific default methods . how to add platform specific run time delegate methods in Ios here.

NickIliev commented 5 years ago

@NickIliev this default core module has very less number of delegate methods. I want to override more platform specific default methods . how to add platform specific run time delegate methods in Ios here.

Yes, but what is the issue you are dealing with? You should be able to overwrite all methods just as done with the ones that are already handled.

RajkumarRepo commented 5 years ago

@NickIliev I implement the code but that are not worked properly. In my code any Issue is there.

NickIliev commented 5 years ago

@RajkumarRepo it is not clear what you mean by not worked properly. In my code, any Issue is there.. You can use this thread as a reference to create your own delegate method for the search bar.

CLosing the issue as how-to related but if you are still experiencing troubles, then please consider providing a sample demo app of what you have done so far.

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.