2015-08-20 56 views
0

我們正在iOS 9(beta)設備中測試我們的應用程序。加載表格視圖時應用程序崩潰。但是,同樣的代碼在iOS版8.執行以及tableView滾動問題Xamarin.ios

請在下面找到

當前代碼段

表視圖數據源代碼

public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) 
{ 
    tableView.RegisterNibForCellReuse(UINib.FromName("summaryListCell", NSBu ndle.MainBundle), "summaryListCell"); 
    summaryListCell cell = (summaryListCell)tableView.DequeueReusableCell(new NSString("summaryListCell"), indexPath); 

    cell.SetNeedsLayout(); 

    return cell; 
} 

的TableView Cell類

using System; 
using CoreGraphics; 
using Foundation; 
using UIKit; 
using WBid.WBidiPad.Model; 
using WBid.WBidiPad.SharedLibrary; 
using System.Linq; 
using WBid.WBidiPad.Core; 
using System.Collections.Generic; 

namespace WBid.WBidiPad.iOS 
{ 

    public partial class summaryListCell : UITableViewCell 
    { 
     public static readonly UINib Nib = UINib.FromName("summaryListCell", NSBundle.MainBundle); 
     public static readonly NSString Key = new NSString("summaryListCell"); 

     public summaryListCell(IntPtr handle) : base(handle) 
     {       
      laySubViews (this);  
     } 

     public static summaryListCell Create() 
     { 
      summaryListCell cell = (summaryListCell)Nib.Instantiate(null, null)[0]; 
      return cell; 
     } 

     public static void laySubViews(summaryListCell cell) 
     { 
      Console.WriteLine (cell); 
      UIImageView imgBack = new UIImageView(); 
      imgBack.Frame = new CGRect (0, 0, 900, 50); 
      imgBack.Tag = 1010; 
      cell.ContentView.AddSubview(imgBack); 
     } 
    } 
} 

經過大量的思考和研究,我改變了一些代碼。初始化單元格後,我調用佈局子視圖()類。下面

請找到代碼修改代碼段

表視圖數據源

public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) 
{ 
    tableView.RegisterNibForCellReuse(UINib.FromName("summaryListCell", NSBu ndle.MainBundle), "summaryListCell"); 
    summaryListCell cell = (summaryListCell)tableView.DequeueReusableCell(new NSString("summaryListCell"), indexPath); 
    // Added layoutsubview calling after initialization 
    cell.laySubViews(cell);   
    cell.SetNeedsLayout(); 

    return cell; 
} 

的TableView Cell類

using System; 
using CoreGraphics; 
using Foundation; 
using UIKit; 
using WBid.WBidiPad.Model; 
using WBid.WBidiPad.SharedLibrary; 
using System.Linq; 
using WBid.WBidiPad.Core; 
using System.Collections.Generic; 

namespace WBid.WBidiPad.iOS 
{ 

    public partial class summaryListCell : UITableViewCell 
    { 
     public static readonly UINib Nib = UINib.FromName("summaryListCell", NSBundle.MainBundle); 
     public static readonly NSString Key = new NSString("summaryListCell"); 

     public summaryListCell(IntPtr handle) : base(handle) 
     {  
      // Removed the layoutsubview calling method      
      // laySubViews(this);  
     } 

     public static summaryListCell Create() 
     { 
      summaryListCell cell = (summaryListCell)Nib.Instantiate(null, null)[0]; 
      return cell; 
     } 

     // Changed the static property from laySubViews method 
     public void laySubViews(summaryListCell cell) 
     { 
      Console.WriteLine (cell); 
      UIImageView imgBack = new UIImageView(); 
      imgBack.Frame = new CGRect (0, 0, 900, 50); 
      imgBack.Tag = 1010; 
      cell.ContentView.AddSubview(imgBack); 
     } 
    } 
} 

利用上述變形例中,代碼段工作在兩個iOS 8的和iOS 9.

我們在TableView中加載了400行(這只是一個數字,我們正在動態加載TableView)。現在,TableView的滾動性能出現問題。 TableView在滾動TableView時掛起。

您能否給我一個適用於iOS 8和iOS 9的解決方案?

請在下面找到系統詳細信息。我們在設備中測試iOS 9,我們在下面的配置中部署應用程序,並且使用此配置獲取準確的崩潰錯誤(我們在此配置中獲得的錯誤與我們從App Store下載的應用程序中得到的錯誤相同)

=== ====== ====== Xamarin工作室====== ====== ===

版5.9.3(版本1)安裝UUID: d1449294-29ae-49f6-ab88-23f11a709f17運行時:單聲道4.0.1 ((獨立/ ed1d3ec)GTK + 23年2月24日(羅利主題)

包版本:400010044

===蘋果開發工具===

的Xcode 6.3(7569)建立6D570

=== Xamarin.iOS ===

版本:8.10.1。64(商業版)哈希:e6ebd18科:主 生成日期:2015年5月21日21:55:09-0400

===建設信息===

發佈ID:509030001 Git的版本: 5a524e1726ed103fdd4fe37e0356f2b35466ce9d生成日期:2015年6月2日 16:35:08-04 Xamarin加載項:51957cfbd06be911b212671ad05c2c6221ac90f9

===操作系統===

的Mac OS X 10.10.3達爾文Deepaks,Mac.local 14.3.0達爾文內核版本 14.3。 0 週一年03月23 11點59分05秒PDT 2015 根:XNU-2782.20.48〜5/RELEASE_X86_64 x86_64的

=== ====== ====== ====== ====== ====== ===

你能否給我們解決這種情況?

回答

0
  1. 撥打tableView.RegisterNibForCellReuse一次在viewDidLoad。無需每次獲取單元格時註冊它
  2. 調用cell. laySubViews(cell);cell.SetNeedsLayout();是多餘的。我沒有看到你需要這樣做的任何理由。
0

問題是與Xamarin.iOS和我更新Xamarin.iOS最新穩定版本8.10.4.46。現在它在iOS8和iOS 9中完美運行。我沒有更改任何代碼片段。現在我正在使用上面提到的第一個代碼片段。