我使用VisualStudio(Xamario.iOS)中的部件實施表格划動菜單。下面是我的方法「GetCell」使用SWTableViewCell的表格單元划動菜單
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)`<br/>
{
SWTableViewCell.SWTableViewCell cell = null;
cell = (SWTableViewCell.SWTableViewCell)tableView.DequeueReusableCell(cellIdentifier);
if (cell == null)
cell = new SWTableViewCell.SWTableViewCell(UITableViewCellStyle.Subtitle, cellIdentifier);
cell.SetRightUtilityButtons(GetButtons(), 30.5f);
cell.Delegate = new SWTableViewCell.SWTableViewCellDelegate();
cell.TextLabel.Text = tableItems[indexPath.Row];
}
private UIButton[] GetButtons()
{
UIButton[] buttons = new UIButton[1];
UIButton btn = new UIButton();
btn.SetTitle("Delete", UIControlState.Normal);
buttons[0] = btn;
UIImage image = UIImage.FromFile("Profile/Images/house");
btn.SetImage(image, UIControlState.Normal);
return buttons;
}
我不明白在這些方法中的任何異常的代碼,但畢竟這些,我發現了異常在行UIApplication.Main(參數,空「的AppDelegate」 )在Main方法中。
NSInvalidArgumentException Reason: *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
如果我跳過行「SetRightUtilityButtons」,我得到的所有行沒有任何問題。但我想有滑動式的菜單。
我把它解決了。 – 2014-11-14 15:34:20
我有同樣的問題..你是如何解決它的?謝謝! – SimonM 2015-05-27 23:04:06
我不知道我做了什麼。但是如果你能分享你的代碼,我可以解決你的問題。 – 2015-05-29 16:21:09