【发布时间】:2013-07-29 07:14:34
【问题描述】:
在 DialogViewController LoadView 方法上设置 TableView.Frame 似乎没有任何作用是有原因的吗?
目前为了克服这个问题,我将 TableView.ContentInset 设置为顶部,TableView.TableFooterView 设置为底部边距,但这种方法的问题是滚动条不会在表格边界所在的位置开始/结束,例如它会“下” " 底部的 TabBar 等。
有没有办法在DialogViewController中手动设置TableView框架,如果没有,为什么?
谢谢。
更新:我期望应该可以正常工作的示例代码,例如更改 TableView 框架? 注意:如果我在 ViewDidAppear 中设置 Frame 则它可以工作,但我需要它在 ViewDidLoad 中工作。
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Drawing;
using MonoTouch.Dialog;
namespace Test
{
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
UIWindow window;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
var vc = new MainViewController ();
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.RootViewController = vc;
window.MakeKeyAndVisible ();
return true;
}
}
[Register]
public class MainViewController : DialogViewController
{
public MainViewController (): base (UITableViewStyle.Plain, new RootElement (""))
{
TableView.AutoresizingMask = UIViewAutoresizing.None;
Section s = new Section ("Section 1");
Root.Add (s);
StringElement el = new StringElement ("Element 1");
s.Add (el);
el = new StringElement ("Element 2");
s.Add (el);
s = new Section ("Section 2");
Root.Add (s);
el = new StringElement ("Element 1");
s.Add (el);
el = new StringElement ("Element 2");
s.Add (el);
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
TableView.Frame = new RectangleF (0, 120, TableView.Frame.Width, TableView.Frame.Height - 120);
}
}
}
【问题讨论】:
-
见stackoverflow.com/a/18282916/7561,同样的问题有一个很好的解决方案。
标签: uitableview xamarin.ios frame dialogviewcontroller