【问题标题】:Monotouch / Xamarin changing the table row height for iPad applicationsMonotouch / Xamarin 更改 iPad 应用程序的表格行高
【发布时间】:2014-07-28 21:52:55
【问题描述】:

我无法弄清楚如何在我的Xamarin iPad 应用程序中更改表的rowHeight。以前我在 iPhone 应用程序上工作过,调整行的大小就像在 TableSource 类中调用以下代码一样简单:

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

但是,我发现 iPad 应用程序中没有调用它。我应该调用另一种方法还是我完全错误地解决了这个问题?

【问题讨论】:

  • 不熟悉 Xamarin,但在 Objective-C 中,您只需设置表格视图的 rowHeight 属性即可。

标签: ios uitableview ipad xamarin xamarin.ios


【解决方案1】:

看起来您通过覆盖 GetHeightForRow 来正确执行此操作,但如果它没有更改它,我建议您检查控制器上的 ViewDidLoad 方法,以确保它将 tableview 源设置为您的自定义 tableSource 类。

例如在ViewDidLoad

_tableview.Source = new TableSource();

【讨论】:

    【解决方案2】:

    简单的方法。创建您的自定义电视:

    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;
    
            }
    
        }
    

    如果您不想创建自己的,只需更改表上的属性RowHeight。 并且不要忘记在情节提要中为 TableView 或 Id 创建一个类。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 2021-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多