Hey All,
I'm very new to Xamarin, and though there are some threads that seem to deal with similar issues, I am having a heck of a time getting a VERY simple custom button added to my UITableViewCell without its TouchUpInside event causing the horrible crash that everyone has run into. I would great appreciate any advice as to what exactly I'm doing wrong here. Thanks in advance!
// Customize the appearance of table view cells.
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
var cell = (UITableViewCell)tableView.DequeueReusableCell (CellIdentifier, indexPath);
cell.TextLabel.Text = objects [indexPath.Row].ToString ();
var button = new UIButton (UIButtonType.System);
button.TouchUpInside += (sender, e) =>
{
// var buttonCell = ((UIButton)sender).Superview as UITableViewCell; string s = "string"; // var cellIndex = tableView.IndexPathForCell(buttonCell); // var objectInstance = objects[cellIndex.Item]; };
button.SetTitle ("Submit", UIControlState.Normal);
button.Frame = new System.Drawing.RectangleF (150.0f, 5.0f, 150.0f, 30.0f);
cell.AddSubview (button);
return cell;
}