Custom Button Event

Hi everbody, Im new developer Xamarin.IOS so i have a problem with custom event.

I create custom view and button. Code is here:

` public static UIButton FacebookLoginButton (string title, string imagePath)
{
var image = UIImage.FromFile (imagePath);

        var button = UIButton.FromType (UIButtonType.Custom);

        button.SetTitle (title, UIControlState.Normal);
        button.SetTitleColor (FitpulseTheme.SharedTheme.SecondaryColor, UIControlState.Normal);
        button.SetTitleShadowColor (UIColor.White, UIControlState.Normal);

        button.SetTitleColor (UIColor.White, UIControlState.Highlighted);
        button.SetTitleShadowColor (FitpulseTheme.SharedTheme.ShadowColor, UIControlState.Highlighted);

        button.SetImage (image, UIControlState.Normal);

        button.Font = UIFont.SystemFontOfSize (24);         
        button.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
        button.AdjustsImageWhenHighlighted = true;          

        button.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
        button.ImageEdgeInsets = new UIEdgeInsets (0, 9, 4, 0);
        //button.TitleEdgeInsets = new UIEdgeInsets (0, 19, 4, 0);

        return button;


    }`

than create view class

`public class LoginView:UIView
{
UIView _loginView;
UILabel _lblStatus;
UIButton _btnLogin;
UIImageView _loginImage;

    public LoginView ()
    {

            InitSubViews ();
            ApplyStyles();

    }

    public void InitSubViews()
    {
        var image = UIImage.FromFile ("loginBackground.png");


        if (_loginView == null) {

            _loginView = new UIView ();
            _loginView.BackgroundColor = UIColor.FromPatternImage (image);
            _loginView.Frame = new RectangleF (_loginView.Frame.Location,image.Size);


            _btnLogin = Buttons.FacebookLoginButton("Muhammet","loginWithFacebook.png");
            _btnLogin.Frame = new RectangleF (10, _loginView.Frame.Bottom + 300, 289, 39);
            _btnLogin.TouchUpInside += delegate 
            {
                //DO something....


            };

            _loginView.AddSubviews (_btnLogin);

            Add (_loginView);
        }

    }

}
}`

`public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{

        _facebookLoginStringElement = new StyledStringElement ("",LoginToFacebook);
        _facebookLoginStringElement.Image = UIImage.FromFile ("loginWithFacebook.png");
        _facebookLoginStringElement.BackgroundColor = UIColor.Clear;
        var loginView = new LoginView();

        facebook = new Section ();
        facebook.Add (loginView);

        dialog = new DialogViewController (new RootElement ("Kullanıcı Giriş") {
            facebook,
        });



        // create a new window instance based on the screen size
        window = new UIWindow (UIScreen.MainScreen.Bounds);


        window.RootViewController = new UINavigationController (dialog);;
        // make the window visible
        window.MakeKeyAndVisible ();

        return true;
    }

`
project build and start debug, but button touchupinside event didnt work:( How can implement event and how can i solve problem. Thank you

Sign In or Register to comment.