Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

i m unable to call delegate method this my code

$
0
0
public partial class CommentCell : UITableViewCell, IUITextViewDelegate
{
    public static readonly NSString Key = new NSString("CommentCell");
    public static readonly UINib Nib;
    nfloat currentScreenHeight;
    TypedWeakReference<NewIncidentViewController> parentVC;
    static CommentCell()
    {
        Nib = UINib.FromName("CommentCell", NSBundle.MainBundle);

    }

    public override void AwakeFromNib()
    {
        commentTextView.Delegate = this;

    }

    public void SetParent(NewIncidentViewController parentViewC)
    {
        this.parentVC = new TypedWeakReference<NewIncidentViewController>(parentViewC);
    }

    protected CommentCell(IntPtr handle) : base(handle)
    {
        // Note: this .ctor should not contain any initialization logic.
    }

    public void UpdateCell()
    {

        currentScreenHeight = UIScreen.MainScreen.Bounds.Height;

        commentTextView.Layer.CornerRadius = 10;
        commentTextView.ClipsToBounds = true;
        commentTextView.Layer.BorderWidth = 1;
        commentTextView.Layer.BorderColor = AppConstants.RedikerTeal.CGColor;
        commentTextView = new PlaceholderTextView(new CGRect(0f, 0f,  515f , 400f))
        {
           Placeholder = "Enter comment"
        };
    }

    public bool ShouldBeginEditing(IUITextViewDelegate This, UITextView textView)
    {
        textView.Text = "fsd";
        return true;
    }

    public bool ShouldEndEditing(IUITextViewDelegate This, UITextView textView)
    {
        return true;
    }

    public  void Changed(IUITextViewDelegate This, UITextView textView)
    {
        textView.Text = "fsd";

    }

    //void KeyBoardUpNotification()
    //{
    //    if (currentScreenHeight == AppConstants.iPhone5Height)
    //    {
    //        BeginAnimations(null);
    //        SetAnimationBeginsFromCurrentState(true);
    //        parentVC.Target.View.Frame = new CGRect(parentVC.Target.View.Frame.X, parentVC.Target.View.Frame.Y - 100, parentVC.Target.View.Frame.Width, parentVC.Target.View.Frame.Height);
    //        CommitAnimations();
    //    }
    //}

    //private void KeyBoardDownNotification()
    //{
    //    if (currentScreenHeight == AppConstants.iPhone5Height)
    //    {
    //        BeginAnimations(null);
    //        SetAnimationBeginsFromCurrentState(true);
    //        parentVC.Target.View.Frame = new CGRect(parentVC.Target.View.Frame.X, parentVC.Target.View.Frame.Y + 100, parentVC.Target.View.Frame.Width, parentVC.Target.View.Frame.Height);
    //        CommitAnimations();
    //    }
    //}

}

}
public class PlaceholderTextView : UITextView
{
///


/// Gets or sets the placeholder to show prior to editing - doesn't exist on UITextView by default
///

public string Placeholder { get; set; }

public PlaceholderTextView()
{
    Initialize();
}

public PlaceholderTextView(CGRect frame)
    : base(frame)
{
    Initialize();
}

public PlaceholderTextView(IntPtr handle)
    : base(handle)
{
    Initialize();
}

void Initialize()
{
    Placeholder = "Enter comment";

    ShouldBeginEditing = t => {
        if (Text == Placeholder)
            Text = string.Empty;
        TextColor = UIColor.Red;
        return true;
    };
    ShouldEndEditing = t => {
        if (string.IsNullOrEmpty(Text))
            Text = Placeholder;
        TextColor = UIColor.Red;
        return true;
    };
}

}


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>