【发布时间】:2019-09-05 14:22:12
【问题描述】:
我正在为我组织中的所有工程师创建 IOS 应用程序,以查看和完成他们的工作。但是,当使用 UIScrollView 时,它会将内容从我放置在故事板上的位置移开。
使用普通 UIView(不滚动),元素放置在我放置它们的位置,但是如果页面上有大量开关(动态)放置,它可能会溢出,因此我需要能够滚动浏览项目。
我正在使用storyboard here。创建我的主要布局。 但是,在我的滚动布局中,我使用此代码添加按钮。
y = StartY
x = StartX
foreach (var component in DetailItem.Components)
{
y += yPls;
UISwitch sw = new UISwitch(new CoreGraphics.CGRect(x, y, 51, 31));
sw.OnTintColor = UIColor.Yellow;
sw.ThumbTintColor = UIColor.Blue;
sw.ValueChanged += (sender, e) => {
var comp = sender as UISwitch;
DetailItem.Components[component.Key] = comp.On;
};
UILabel lbl = new UILabel(new CoreGraphics.CGRect(x + 55, y, 200, 31));
lbl.Text = component.Key;
this.Add(sw);
this.Add(lbl);
}
问题是元素正在从我放置它们的位置移动,如下所示:
我目前选择了“工作名称:”标签,但您可以看到它正在被移动。
任何有关此问题的帮助或有关其发生原因的想法都会很棒!
【问题讨论】:
标签: c# xamarin.ios xcode-storyboard