I followed this tutorial in order to create a custom Cell.
I have created a custom cell in the Interface Builder that looks like that:
In my ViewController i have added a UITableView and bind it to a data:
myTable.Source = new ListSource();
The GetCell method of the ListSource:
public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
// Reuse a cell if one exists
CustomListCell cell = tableView.DequeueReusableCell ("QCell") as CustomQuestionsListCell;
if (cell == null)
{
// We have to allocate a cell
var views = NSBundle.MainBundle.LoadNib ("CustomListCell", tableView, null);
cell = Runtime.GetNSObject (views.ValueAt (0)) as CustomListCell;
}
return cell;
}
The problem is that the display in the end looks like that:
It seems like there some kind of over lapping. Any ideas why is this happening?
Thanks!
You need to set the table view's RowHeight
to whatever the view height is in IB. This should be myTable.RowHeight = ...
.
If you have different heights for each row, you can use GetHeightForRow
in the delegate but this is much slower, causing the table view to iterate through all cells before the first rendering (so it can calculate scroll height).
You need to set the RowHeight for the Custom Cell your are using in your project . Since your are not providing any height , the Table is allocating default to the TableViewCell . RowHeight provided by you should be same as that in the Interface Builder (IB) .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.