【问题标题】:Inherit/Set the BackgroundView for RadioGroup generated DialogViewController TableView (MonoTouch.Dialog)为 RadioGroup 生成的 DialogViewController TableView (MonoTouch.Dialog) 继承/设置 BackgroundView
【发布时间】:2011-10-26 00:27:24
【问题描述】:

我想使用 MonoTouch.Dialog RadioElements 来选择数据,它必须有一个 UIImageView 用于 TableView BackgroundViews。

我可以在初始 DialogViewController 的 TableView 上设置 BackgroundView,所以那里没有问题,但是为每个 RadioGroup 生成的 TableView 具有默认的灰色背景图像,我似乎无法找到将它们更改为相同背景样式的方法最初的 TableView。

是否可以更改生成的 TableView 的 BackgroundView(为每个 RadioGroup 生成的 TableView)而无需去修改 MonoTouch.Dialog 源?

提前致谢。

【问题讨论】:

  • 对不起,我看错了你原来的问题。我的印象是RadioGroup 与 UI 无关,即没有表格(需要再次检查)。可能是 RootElement 的 TableView 吗?如果是这样,同样的继承和覆盖技巧就可以了。
  • 是的,我之前发现的。谢谢!
  • 那么最终的答案是什么?

标签: c# iphone ios xamarin.ios monotouch.dialog


【解决方案1】:

AFAIK 您需要创建自己的元素。但消息是这很容易做到,例如:

public class TransparentRootElement : RootElement {

    // add required .ctors

    public override UITableViewCell GetCell (UITableView tv)
    {
        var cell = base.GetCell (tv);
        cell.BackgroundColor = UIColor.Clear;
        return cell;
    }
}

那么你只需要在你创建RadioGroup的地方使用这个新的TransparentRootElement类型。

【讨论】:

  • 我正在尝试设置 TableView 本身的背景,而不是单个单元格。
【解决方案2】:
public class CustomRootElement : RootElement
{
    public CustomRootElement(string caption, RadioGroup group) : base(caption, group)
    {

    }
    protected override MonoTouch.UIKit.UIViewController MakeViewController()
    {
        DialogViewController result = (DialogViewController)base.MakeViewController();
        // set the background here
        result.TableView.BackgroundColor = UIColor.ScrollViewTexturedBackgroundColor;

        return result;
    }

}

【讨论】:

    猜你喜欢
    • 2011-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-08
    • 1970-01-01
    • 2011-06-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多