在滚动视图的可见区域之外创建的视图上的触摸事件 [英] touch events on views created outside visible area on scrollview
问题描述
所以我有这个视图结构的问题:
So I have this problem where I have this view structure:
控制器->视图->滚动视图->主视图
Controller->View->ScrollView->mainview
我有一个按钮加载在主视图中,但在滚动视图的可见内容之外.当我向上滚动以查看按钮时,触摸不起作用,但如果我将要加载的按钮放置在可见区域,它会起作用.
and I have a button that's loaded in the mainview, but outside of scrollview's visible content. When I scroll up to see the button, the touch doesn't work, but if I place the button to load in the visible area it works.
我还尝试使用简单的图像视图并设置手势识别器(启用用户交互),问题完全相同.
I also tried with a simple imageview and setting a gesture recognizer (with user interaction enabled) and the problem is exactly the same.
这是我定义按钮的地方:
This is where I define the button:
UIButton scrapbookbackground = new UIButton(new CGRect(SPACING, progresses_view.Frame.Y + progresses_view.Frame.Height + SPACING, View.Frame.Width - SPACING * 2, 90));
scrapbookbackground.BackgroundColor = UIColor.Clear.FromHex(0x4f80bc);
scrapbookbackground.Layer.CornerRadius = 10f;
scrapbookbackground.Layer.BorderWidth = 1f;
scrapbookbackground.Layer.BorderColor = UIColor.Blue.CGColor;
scrapbookbackground.ClipsToBounds = true;
scrapbookimg = UIImage.FromFile("Images/scrap_capa.png");
scrapbookbackground.SetBackgroundImage(scrapbookimg, UIControlState.Normal);
scrapbookbackground.TouchUpInside += (args, e) => {
Console.WriteLine("scrapbooktouch");
NavigationController.PushViewController(new ScrapBookPageViewController(), true);
};
mainview.Add(scrapbookbackground);
推荐答案
想通了.没有正确设置滚动视图的内容大小.
figured it out. was not setting contentsize of scrollview properly.
这篇关于在滚动视图的可见区域之外创建的视图上的触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!