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

帶有 UIButtons 的 UIScrollview - 如何重新創(chuàng)建跳板?

UIScrollview with UIButtons - how to recreate springboard?(帶有 UIButtons 的 UIScrollview - 如何重新創(chuàng)建跳板?)
本文介紹了帶有 UIButtons 的 UIScrollview - 如何重新創(chuàng)建跳板?的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

我正在嘗試在我的應(yīng)用程序中創(chuàng)建一個(gè)類似跳板的界面.我正在嘗試使用添加到 UIScrollView 的 UIButtons.我遇到的問(wèn)題是按鈕沒(méi)有將任何觸摸傳遞給 UIScrollView - 如果我嘗試輕彈/滑動(dòng)并碰巧按下按鈕,它不會(huì)注冊(cè) UIScrollView,但是如果我輕彈之間的空間按鈕它將起作用.如果我觸摸它們,按鈕會(huì)單擊/工作.

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.

是否有強(qiáng)制按鈕將觸摸事件發(fā)送到其父級(jí)(超級(jí)視圖)的屬性或設(shè)置?在添加 UIScrollView 之前是否需要將按鈕添加到其他內(nèi)容?

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 確定點(diǎn)擊進(jìn)入其內(nèi)容視圖和觸摸轉(zhuǎn)動(dòng)之間的區(qū)別滑動(dòng)或捏合時(shí),它需要延遲觸摸并查看您的手指是否在此延遲期間移動(dòng).通過(guò)在上面的示例中將 delaysContentTouches 設(shè)置為 NO,您可以防止這種情況發(fā)生.因此,滾動(dòng)視圖總是將觸摸傳遞給按鈕,而不是在用戶執(zhí)行滑動(dòng)手勢(shì)時(shí)取消它.嘗試將 delaysContentTouches 設(shè)置為 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.

從結(jié)構(gòu)上講,將要在滾動(dòng)視圖中托管的所有視圖添加到公共內(nèi)容視圖并僅使用該視圖作為滾動(dòng)視圖的子視圖,這也是一個(gè)好主意.

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.

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

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

相關(guān)文檔推薦

How to subclass UIScrollView and make the delegate property private(如何繼承 UIScrollView 并使委托屬性私有)
Swift - how to get last taken 3 photos from photo library?(Swift - 如何從照片庫(kù)中獲取最后拍攝的 3 張照片?)
Setting contentOffset programmatically triggers scrollViewDidScroll(以編程方式設(shè)置 contentOffset 觸發(fā) scrollViewDidScroll)
Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁(yè)面之間的照片應(yīng)用程序式間隙)
why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動(dòng)時(shí)暫停 NSTimer)
主站蜘蛛池模板: 亚洲最大av | 久久精品亚洲成在人线av网址 | 亚洲第一视频网站 | 日韩三区在线观看 | 台湾a级理论片在线观看 | 中文字幕在线观看 | 亚洲一区国产 | 精品亚洲一区二区三区四区五区 | 国产精品一区网站 | 日韩一区二区不卡 | 国产高清视频一区 | 黄色一级视频 | 国产精品日韩欧美一区二区三区 | 国产农村妇女精品一二区 | 国产黄色大片在线免费观看 | 成人免费一区二区三区牛牛 | 久久av资源网 | 黄色免费在线网址 | 伊人伊人| 久久精品国产一区二区电影 | 黄色片大全在线观看 | 国际精品鲁一鲁一区二区小说 | h小视频 | 久久久久网站 | 91国在线| 欧美日韩国产高清 | 一级爱爱片 | 亚洲国内精品 | 国产91一区 | 亚洲天堂免费在线 | 国产成人精品一区二区三区视频 | 久久成人精品 | 国产精品成人一区二区三区夜夜夜 | 久久久精品一区二区 | 免费观看一级视频 | 中文字幕一区二区三区在线观看 | 亚洲精品电影在线观看 | 国产毛片毛片 | 男人天堂社区 | 一区二区在线 | 欧美日韩中文字幕在线 |