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

如何以編程方式創建 UIScrollView?

How to create a UIScrollView Programmatically?(如何以編程方式創建 UIScrollView?)
本文介紹了如何以編程方式創建 UIScrollView?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

好的,這里的關鍵是我根本沒有使用 IB,因為我正在使用的視圖是通過編程方式創建的.UIView 覆蓋了屏幕的下半部分,上面有一堆按鈕.但是,我想在 UIView 中添加更多按鈕,而不使其變得更大.為此,我想在視圖中創建一個 UIScrollView,這將允許我在屏幕外添加更多按鈕,以便用戶可以滾動到它們.我認為這就是它的工作原理.

Alright, so the key here is I'm not using IB at all, because the View I'm working with is created programmatically. The UIView covers the lower half the screen, and has a bunch of buttons on it. However, I want to add more buttons to the UIView, without making it any larger. To do so, I want to make a UIScrollView inside the view, which will allow me to add more buttons off screen so the user can scroll to them. I think that's how it works.

self.manaView = [[[UIView alloc] initWithFrame:frame] autorelease];
self.manaView.backgroundColor = [UIColor purpleColor];

UIScrollView *scroll = [UIScrollView alloc];
scroll.contentSize = CGSizeMake(320, 400);
scroll.showsHorizontalScrollIndicator = YES;
[self.manaView addSubview:scroll];

代碼的第一部分啟動了我的 UIView,效果很好,但我不知道如何以編程方式制作 UIScrollView 并將其添加到視圖中,然后向其中添加按鈕.

The first part of the code iniates my UIView, which works great, but I can't figure out how to make the UIScrollView programmatically and add it to the view, and then add the buttons to it.

UIButton *ret2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
ret2.tag = 102;
ret2.frame = CGRectMake(255, 5, 60, 50);
[ret2 setTitle:@"Return" forState:UIControlStateNormal];
[ret2 addTarget:self action:@selector(flipAction:) forControlEvents:UIControlEventTouchUpInside];
[scroll addSubview:ret2];

當我這樣做時,按鈕從我的屏幕上消失了.那么我該如何正確地做到這一點呢?感謝您的幫助!

When I did that, the button simply disappeared off my screen. So How do I do this correctly? Thank you for your help!

推薦答案

代替:

UIScrollView *scroll = [UIScrollView alloc];

執行此操作(將框架設置為您希望滾動視圖的大小):

do this (setting the frame to however big you want the scroll view to be):

UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:...];

這篇關于如何以編程方式創建 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)
主站蜘蛛池模板: 日本超碰| 91日韩| 91就要激情 | 日本一区二区高清不卡 | 超碰91在线 | 国产成人精品a视频一区www | 欧美日韩一区二区在线观看 | 久久久久久高清 | 欧美日韩一区二区三区四区 | 一区二区三区国产精品 | 亚洲播放一区 | 日韩久久精品 | 亚洲精品视频免费 | 一区二区三区四区在线视频 | 狠狠av | 色狠狠桃花综合 | 手机看片在线播放 | 狠狠婷婷综合久久久久久妖精 | 99视频免费在线观看 | 国产精品免费在线 | 久国产视频 | www国产亚洲精品久久网站 | 天天射美女 | 午夜影视| 黑人巨大精品 | 国际精品久久 | 午夜伊人 | 在线亚洲一区 | 欧美专区在线视频 | 亚洲一区免费视频 | 精品国产亚洲一区二区三区大结局 | 国产精品成人国产乱 | 6996成人影院网在线播放 | 成人免费视频在线观看 | 精品一区二区三区中文字幕 | 久在线观看 | 国产色| 久久久久久久久久久一区二区 | 91麻豆精品国产91久久久久久 | 免费一区二区在线观看 | 九九热免费视频在线观看 |