我正在尝试使屏幕滚动。我正在使用ViewController插入背景为白色的多个UIView,而ViewController背景为灰色。在UIviews中,我有多个按钮,我想添加更多内容。但是我无法做到这一点,因为我需要向下滚动。我最近在Xamarin iOS上,并且在应用程序委托中,我正在这样做:
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
{
ViewController v = new ViewController();
Window = new UIWindow(UIScreen.MainScreen.Bounds);
Window.MakeKeyAndVisible();
Window.RootViewController.View = v.View;
return true;
}
这(UIScree.MainScreen.Bounds)是否禁用滚动?我怎么解决这个问题?我尝试使用UIScrollView,但已经完成的工作消失了,不应该这样做,对吧?还是我必须重新做一遍所有这些? 我正在用代码完成这一切。
谢谢!
答案 0 :(得分:0)
我认为您需要的是ViewController中的UIScrollView,您是否尝试过类似的方法:
var scrollView = new UIScrollView (
new CGRect (0, 0, View.Frame.Width, View.Frame.Height));
View.AddSubview (scrollView);
然后将所有视图(而不是主视图)添加到ScrollView中!
编辑:
您完成的发射将类似于:
ViewController v = new ViewController();
Window = new UIWindow(UIScreen.MainScreen.Bounds);
Window.MakeKeyAndVisible();
Window.RootViewController= v
return true;
然后在ViewController中,按如下所示添加View:
var scrollView = new UIScrollView (
new CGRect (0, 0, View.Frame.Width, View.Frame.Height));
View.AddSubview (subView); // Where SubView is the UIView that has your ui design
答案 1 :(得分:0)
这里是:
//创建我们的滚动视图
scrollView =新的UIScrollView(新的CGRect(0,0,View.Frame.Width,View.Frame.Height)); View.AddSubview(scrollView);
//创建图片视图
imageView =新的UIImageView(UIImage.FromFile(“ Germany.jpg”)); scrollView.ContentSize = imageView.Image.Size; scrollView.AddSubview(imageView);