【发布时间】:2016-02-25 16:40:51
【问题描述】:
我正在使用 Xamarin + Mvvmcross 开发应用程序。目前它在 iPad Mini、iPad 2,3、iPhone 5S 和 6 上运行良好。奇怪的是,其中一个视图在运行 iOS 7.1 的 iPhone 4S 上崩溃了。所有测试均使用真实设备完成。
这是崩溃:
https://gist.github.com/nunohorta/2b84245899e8c0daa116
表格源代码是这个:
public class MessagesTableSource : MvxStandardTableViewSource
{
UITableView _tableview;
MessagesView _parent;
UILabel messageLabel;
private static readonly NSString MessageCellIdentifier = new NSString("MessageCell");
public MessagesTableSource(UITableView tableView, MessagesView parent) : base(tableView)
{
_tableview = tableView;
_parent = parent;
}
public override nint RowsInSection (UITableView tableview, nint section)
{
return _parent.ViewModel.Messages != null ? _parent.ViewModel.Messages.Count : 0;
}
public override nint NumberOfSections (UITableView tableView)
{
if (_parent.ViewModel.Messages != null && _parent.ViewModel.Messages.Count > 0) {
return 1;
} else {
/*
* Custom View here
*
* */
return 0;
}
}
protected override UITableViewCell GetOrCreateCellFor (UITableView tableView, NSIndexPath indexPath, object item)
{
var cell = (MessageCell)tableView.DequeueReusableCell("MessageCell");
return cell;
}
}
我也在 viewDidLoad 上注册这样的自定义类:
tableView.RegisterNibForCellReuse(UINib.FromName("MessageCell", NSBundle.MainBundle), MessageCellIdentifier);
我不知道为什么它只是在一个设备上崩溃...崩溃似乎发生在 UIKit/CoreFoundation 上。
【问题讨论】:
-
FIXED> 看起来由于某种原因,我有一个整数类型的运行时属性,其值 5 在我的 xib 文件中定义。出于某种神奇的原因,iOS 在 7.1 上崩溃了,但在其他版本上却没有。
标签: c# ios uitableview xamarin mvvmcross