久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

帶有 UIButtons 的 UIScrollview - 如何重新創建跳板?

UIScrollview with UIButtons - how to recreate springboard?(帶有 UIButtons 的 UIScrollview - 如何重新創建跳板?)
本文介紹了帶有 UIButtons 的 UIScrollview - 如何重新創建跳板?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試在我的應用程序中創建一個類似跳板的界面.我正在嘗試使用添加到 UIScrollView 的 UIButtons.我遇到的問題是按鈕沒有將任何觸摸傳遞給 UIScrollView - 如果我嘗試輕彈/滑動并碰巧按下按鈕,它不會注冊 UIScrollView,但是如果我輕彈之間的空間按鈕它將起作用.如果我觸摸它們,按鈕會單擊/工作.

I'm trying to create a springboard-like interface within my app. I'm trying to use UIButtons added to a UIScrollView. The problem I'm running in to is with the buttons not passing any touches to the UIScrollView - if I try to flick/slide and happen to press on the button it doesn't register for the UIScrollView, but if I flick the space between buttons it will work. The buttons do click/work if I touch them.

是否有強制按鈕將觸摸事件發送到其父級(超級視圖)的屬性或設置?在添加 UIScrollView 之前是否需要將按鈕添加到其他內容?

Is there a property or setting that forces the button to send the touch events up to its parent (superview)? Do the buttons need to be added to something else before being added the UIScrollView?

這是我的代碼:

//init scrolling area
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 480, 480)];
scrollView.contentSize = CGSizeMake(480, 1000);
scrollView.bounces = NO;
scrollView.delaysContentTouches = NO;

//create background image
UIImageView *rowsBackground = [[UIImageView alloc] initWithImage:[self scaleAndRotateImage:[UIImage imageNamed:@"mylongbackground.png"]]];
rowsBackground.userInteractionEnabled = YES;

//create button
UIButton *btn = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
btn.frame = CGRectMake(100, 850, 150, 150);
btn.bounds = CGRectMake(0, 0, 150.0, 150.0);
[btn setImage:[self scaleAndRotateImage:[UIImage imageNamed:@"basicbutton.png"]] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];

//add "stuff" to scrolling area
[scrollView addSubview:rowsBackground];
[scrollView addSubview:btn];

//add scrolling area to cocos2d
//this is just a UIWindow
[[[Director sharedDirector] openGLView] addSubview:scrollView];

//mem-mgmt
[rowsBackground release];
[btn release];
[scrollView release];

推薦答案

為了讓 UIScrollView 確定點擊進入其內容視圖和觸摸轉動之間的區別滑動或捏合時,它需要延遲觸摸并查看您的手指是否在此延遲期間移動.通過在上面的示例中將 delaysContentTouches 設置為 NO,您可以防止這種情況發生.因此,滾動視圖總是將觸摸傳遞給按鈕,而不是在用戶執行滑動手勢時取消它.嘗試將 delaysContentTouches 設置為 YES.

In order for UIScrollView to determine the difference between a click that passes through to its content view(s) and a touch that turns into a swipe or pinch, it needs to delay the touch and see if your finger has moved during that delay. By setting delaysContentTouches to NO in your above example, you're preventing this from happening. Therefore, the scroll view is always passing the touch to the button, instead of canceling it when it turns out that the user is performing a swipe gesture. Try setting delaysContentTouches to YES.

從結構上講,將要在滾動視圖中托管的所有視圖添加到公共內容視圖并僅使用該視圖作為滾動視圖的子視圖,這也是一個好主意.

It might also be a good idea, structurally, to add all the views to be hosted in your scroll view to a common content view and only use that one view as the scroll view's subview.

這篇關于帶有 UIButtons 的 UIScrollview - 如何重新創建跳板?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to subclass UIScrollView and make the delegate property private(如何繼承 UIScrollView 并使委托屬性私有)
Swift - how to get last taken 3 photos from photo library?(Swift - 如何從照片庫中獲取最后拍攝的 3 張照片?)
Setting contentOffset programmatically triggers scrollViewDidScroll(以編程方式設置 contentOffset 觸發 scrollViewDidScroll)
Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應用程序式間隙)
why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動時暫停 NSTimer)
主站蜘蛛池模板: 国产三级电影网站 | 国产精品一区二区精品 | 久久精品国产久精国产 | 亚洲综合电影 | 成人免费共享视频 | 欧美成人免费 | 日本在线播放一区二区 | 亚洲影音先锋 | 福利片在线观看 | h片在线观看免费 | 国产你懂的在线观看 | 日韩精品在线一区 | 亚洲精品一区二区三区蜜桃久 | 国产欧美精品一区二区三区 | av中文字幕网站 | 在线观看中文字幕一区二区 | 日韩一区二区在线播放 | 91精品国产综合久久久动漫日韩 | 精品久久久久久久久久久院品网 | 99精品国产一区二区三区 | 男女国产网站 | 亚洲男人的天堂网站 | 成人av一区二区在线观看 | 欧美精品一区三区 | 韩日免费视频 | 精品欧美一区二区精品久久久 | 亚洲精品视频免费 | 亚洲一区精品在线 | 久久com| 51ⅴ精品国产91久久久久久 | 免费一区 | 久久久久久久久久久久久9999 | 色综合欧美 | 国产成人小视频 | 欧美一区二区三区大片 | 精品国产一区二区三区久久狼黑人 | 免费看欧美一级片 | 日韩在线 | 久久伦理中文字幕 | 99精品久久 | 久久精品久久久久久 |