Ios Xamarin Monotouch自定义单元格为空白

Ios Xamarin Monotouch自定义单元格为空白,ios,xamarin.ios,xamarin,custom-cell,Ios,Xamarin.ios,Xamarin,Custom Cell,我有以下自定义单元格: using System; using System.Drawing; using MonoTouch.Foundation; using MonoTouch.UIKit; namespace Zurfers.Mobile.iOS { public class CustomCell : UITableViewCell { UILabel headingLabel, subheadingLabel, priceLabel;

我有以下自定义单元格:

using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace Zurfers.Mobile.iOS
{
    public class CustomCell : UITableViewCell
    {
        UILabel headingLabel, subheadingLabel, priceLabel;
        UIImageView imageService;
        UIImageView star, star2, star3, star4, star5;
        public CustomCell (NSString cellId) : base (UITableViewCellStyle.Default, cellId)
        {
            imageService = new UIImageView();
            star   = new UIImageView();
            star2  = new UIImageView();
            star3  = new UIImageView();
            star4  = new UIImageView();
            star5  = new UIImageView();
            headingLabel = new UILabel(){
                Font = UIFont.FromName("Cochin-BoldItalic", 22f),
                TextColor = UIColor.FromRGB (127, 51, 0),
            };
            subheadingLabel = new UILabel(){
                Font = UIFont.FromName("Cochin-BoldItalic", 22f),
                TextColor = UIColor.FromRGB (127, 51, 0),
            };
            priceLabel = new UILabel(){
                Font = UIFont.FromName("Cochin-BoldItalic", 22f),
                TextColor = UIColor.FromRGB (127, 51, 0),
            };
        }

        public void UpdateCell (string title, string subtitle, string price, UIImage image)
        {
            imageService.Image = image;
            headingLabel.Text = title;
            subheadingLabel.Text = subtitle;
            priceLabel.Text = price;
        }

        public override void LayoutSubviews ()
        {
            base.LayoutSubviews ();
            imageService.Frame = new RectangleF(63, 5, 33, 33);
            headingLabel.Frame = new RectangleF(5, 4, 63, 25);
            subheadingLabel.Frame = new RectangleF(100, 18, 100, 20);
            priceLabel.Frame = new RectangleF(250, 18, 100, 20);
        }
    }
}
这是我的表源:

using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;

namespace Zurfers.Mobile.iOS
{
    public class HotelTableSource : UITableViewSource
    {

        string[] tableItems;
        NSString cellIdentifier = new NSString("TableCell");

        public HotelTableSource (string[] items)
        {
            tableItems = items;
        }
        public override int RowsInSection (UITableView tableview, int section)
        {
            return tableItems.Length;
        }

        public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
        {
            new UIAlertView("Row Selected", tableItems[indexPath.Row], null, "OK", null).Show();
            tableView.DeselectRow (indexPath, true); // normal iOS behaviour is to remove the blue highlight
        }

        public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
        {

            CustomCell cell = tableView.DequeueReusableCell(cellIdentifier) as CustomCell;
            if (cell == null)
                cell = new CustomCell(cellIdentifier);
            cell.UpdateCell(tableItems[indexPath.Row], tableItems[indexPath.Row], tableItems[indexPath.Row],
                            UIImage.FromFile (tableItems[indexPath.Row]) );
            return cell;


        }
    }
}
但当我运行应用程序时,TableView是空的。在创建TableView之前,每个CustomCell都有一个值

我做错了什么


提前感谢您的帮助。

单元格不仅应包含控件,还应将它们放置在其上(或其
ContentView
)。调用
AddSubview
,查看添加到自定义单元格中的任何控件:

ImageService=newuiimageview();
AddSubview(图像服务);


如果没有帮助,请尝试使用
UITableViewCell
的默认控件(
textlab
detailtextlab
ImageView
)来显示一些数据。如果出现数据,则说明自定义的
UITableViewCell
(错误的框架,空文本)中仍然存在问题,否则,问题出现在
UITableViewSource
(空数据)中。

单元格不仅应包含控件,还应将控件放在其上(或其
ContentView
)。调用
AddSubview
,查看添加到自定义单元格中的任何控件:

ImageService=newuiimageview();
AddSubview(图像服务);

如果没有帮助,请尝试使用
UITableViewCell
的默认控件(
textlab
detailtextlab
ImageView
)来显示一些数据。如果出现数据,则说明自定义的
UITableViewCell
(错误的帧,空文本)中仍然存在问题,否则,问题出现在
UITableViewSource
(空数据)中