문제

I am having trouble figuring out how to change the rowHeight for the tables in my Xamarin iPad application. Previously I've worked on iPhone apps and adjusting the size of the rows were as simple as calling the following in the TableSource Class:

public override float GetHeightForRow (UITableView tableView, NSIndexPath indexPath)
        {
            return 95f;
        }

However, I'm finding out that this is not being called in the iPad app. Is there another method I should be calling or am I just going about this completely wrong?

도움이 되었습니까?

해결책

It looks like you are doing it correctly by overriding GetHeightForRow, but if its not changing it I'd suggest checking your ViewDidLoad method on the controller to make sure it's setting the tableview source to your custom tableSource class.

For example, in ViewDidLoad:

_tableview.Source = new TableSource();

다른 팁

Just easy way. Create your custom TV:

public class CustomTableViewStyle : UITableView
    {
        public CustomTableViewStyle (System.Drawing.RectangleF frame)
        {
            Initialize (frame);
        }

        void Initialize (System.Drawing.RectangleF frame)
        {
            Frame = frame;
            AutoresizingMask = UIViewAutoresizing.All;
            ScrollEnabled = true;
            SectionFooterHeight = 0;
            AllowsSelection = true;
            AllowsMultipleSelection = false;
            SeparatorColor = UIColor.FromRGB (239, 243, 243);
            RowHeight = 210;  <-- // Your table row height!
            SeparatorInset = UIEdgeInsets.Zero;
            DelaysContentTouches = true;
            CanCancelContentTouches = true;

        }

    }

If you do not want to create your own just change the property on your table RowHeight. And dont forget create a class for TableView or Id in storyboard.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top