gpt4 book ai didi

iphone - ***断言失败-[Scrapboom.iPhone.NewsFeedTableView _endCellAnimationsWithContext :],/SourceCache/UIKit/UIKit-2903.2/UITableView.m:1076

转载 作者:行者123 更新时间:2023-11-28 22:24:20 29 4
gpt4 key购买 nike

我在 UITablViewSource 中使用以下代码

 public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
UIImage scaledImage=null;
string cellIdentifier = "NewsFeedCell";
var newsFeedCellItem = NewsFeedCellItemList [indexPath.Row];
var newsFeedCell = new NewsFeedCell (NewsFeedScreenInstance, newsFeedCellItem, cellIdentifier, indexPath);

if (newsFeedCell != null) {
if (!String.IsNullOrWhiteSpace (newsFeedCellItem.FeedItem.Picture.PreviewUrl)) {
var image = ImageStore.Get (newsFeedCellItem.FeedItem.Picture.PreviewUrl);
if(image != null)
{
newsFeedCellItem.FeedItem.Picture.Image = image;
scaledImage = ImageHelper.Scale(image, new SizeF (528, 528));
}
if (scaledImage != null) {
newsFeedCell.ScrapImage = scaledImage;
} else {
BeginDownloadImage (tableView, indexPath);
}

}


}

return newsFeedCell;
}

#endregion

#region PRIVATE METHODS

private void BeginDownloadImage (UITableView tableView, NSIndexPath indexPath)
{
Action successAction = () => {

this.BeginInvokeOnMainThread (() => {
tableView.BeginUpdates ();
tableView.ReloadRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
tableView.EndUpdates ();
});
};

ImageStore.BeginDownloadImage(NewsFeedCellItemList [indexPath.Row].FeedItem.Picture.PreviewUrl, successAction);
}
#endregion

*描述:*但是下面的部分代码给出了异常

* Assertion failure in -[Scrapboom.iPhone.NewsFeedTableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-2903.2/UITableView.m:1076 and application is get hanged or sometimes crashing.

tableView.ReloadRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);

最佳答案

你的 GetCell实现看起来不对。你应该尝试Dequeue一个单元格,如果失败则创建一个单元格(在 iOS6+ 中甚至不需要 Register*ForCellReuse :

public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
string cellIdentifier = "NewsFeedCell";
var newsFeedCell = tableView.DequeueReusableCell (cellIdentifier) as NewsFeedCell;

//only required if you haven't used Register*ForCellReuse
if (newsFeedCell == null)
newsFeedCell = new NewsFeedCell (..., cellIdentifier,...);

//update your cell image and components here.
}

要了解更多信息,请阅读 tutorials .

如果环顾四周,您还会发现行之有效的工作模式,可以在表格单元格中延迟加载图像。并不是说您的第一眼看起来不对,而是这种情况并不常见。

关于iphone - ***断言失败-[Scrapboom.iPhone.NewsFeedTableView _endCellAnimationsWithContext :],/SourceCache/UIKit/UIKit-2903.2/UITableView.m:1076,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19418971/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com