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

UITableView 中的 UIScrollView 和 UIPageControl

UIScrollView and UIPageControl within UITableView(UITableView 中的 UIScrollView 和 UIPageControl)
本文介紹了UITableView 中的 UIScrollView 和 UIPageControl的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我看到很多消息來源說可以在 UITableViewCell 中包含帶有 UIPageControl 的 UIScrollView 以便能夠水平滾動(通過可選圖像列表),但找不到任何可以滿足我要求的原始示例.我的滾動視圖工作"了,但我不確定如何繼續(xù) - 希望有人可以給我一些指導.

I've seen lots of sources saying it is possible to include a UIScrollView with UIPageControl inside a UITableViewCell to be able to scroll horizontally (through a list of selectable images), but can't find any raw examples that does what I want. I've gotten my scroll view "working", but I am unsure how to go forward - hopefully someone can send me some guidance.

在我的 cellForRowAtIndexPath 中,我創(chuàng)建了一個單元格,并將 scrollView 和 pageControl 添加為子視圖.

Within my cellForRowAtIndexPath, I create a cell, and add both a scrollView and pageControl as subviews.

UITableViewCell *cell = [self.challengeListView dequeueReusableCellWithIdentifier:SubmitChallengeCellIdentifier];
    if(cell == nil){
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SubmitChallengeCellIdentifier] autorelease];
        cell.frame = CGRectMake(0, 0, 1000, 50);
    }   

    scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, tv.frame.size.width, 50)];
    [scrollView setContentSize:CGSizeMake(1000, 50)];
    [[cell contentView] addSubview:scrollView];

    pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 50, tv.frame.size.width, 50)];
    [pageControl setNumberOfPages:4];
    [[cell contentView] addSubview:pageControl];

我附上了正在顯示的屏幕截圖

I've attached a screenshot of what's being displayed

主視圖的底部是我的 UITableView,其中包含 scrollView/pageControl(它會水平滾動,因為我可以看到 scrollerIndicator 顯示了這一點),我將它的方法設置為以下:

the bottom portion of the main view is my UITableView that contains the scrollView/pageControl (and it will scroll horizontally, as I can see the scrollerIndicator showing this), and I've got its method's set to the following:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{   
    return 1;
}   

我的滾動視圖將顯示horizo??ntalScroller",我可以來回滾動,但顯然那里沒有內(nèi)容.如何使用可點擊"圖像列表填充 tableView/scrollView?任何方向都將不勝感激 - 最好不是嘿,這家伙做的有點相似,看看這個鏈接",但也許更多的是解釋如何正確實現(xiàn)這個功能(E特別是關(guān)于iOS 3.0+ - 據(jù)我了解,Apple 在實現(xiàn)這一點時讓我們的生活變得更輕松)

My Scroll view will indicate a "horizontalScroller" and I am able to scroll back and forth, but obviously there's no content there. How do I go about populating the tableView/scrollView with say, a list of "clickable" images? Any direction would be greatly appreciated - preferably not a "hey this guy's done it somewhat similar, check out this link" but maybe more an explanation of how this functionality should be implemented correctly (ESPECIALLY in regards to iOS 3.0+ - it is my understanding Apple has made our lives easier in implementing this)

推薦答案

我已經(jīng)解決了自己的問題;也許沒有一次回答我的原因是因為一旦你了解了每個視圖的目的,它就是一個次要的實現(xiàn).

I've solved my own problem; maybe the reason no once answered me is because its a minor implementation once you understand each view's purpose.

cellForRowAtIndexPath: 內(nèi)我創(chuàng)建了一個標準的 UITableViewCell,但是我將單元格的框架更改為我自己的 1000 寬 x 50 高的自定義框架(滿足我對項目的需要).

From within cellForRowAtIndexPath: I created a standard UITableViewCell, however I altered the frame of the cell to my own custom frame of 1000 width by 50 height (catered to my needs for project).

然后我創(chuàng)建了一個 UIScrollView,將其設置為以下內(nèi)容(請記住,我在 IB 中定義了我的 tableView,因此我將我的一些高度/寬度映射到這些值):

I then created a UIScrollView, set it to the following (keep in mind I have my tableView defined in IB, so I'm mapping some of my height/widths to those values):

scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, tv.frame.size.width, 78)];

然后我創(chuàng)建所需的圖像視圖(我意識到接下來我將創(chuàng)建一個循環(huán)來處理許多圖像并將它們布置在滾動視圖中):

I then create the desired image view (I realize I will next create a loop that does many images and lays them out across the scroll view):

UIImage *image = [UIImage imageNamed:@"dummy.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0, 0, 80, 78);
[scrollView addSubview: imageView];

這是我缺少的部分.將 scrollView 添加到單元格內(nèi)容后,您需要使用 UIPageControl (起初對我來說這個實現(xiàn)似乎并不明顯)來設置實際的視覺水平滾動"效果:

Here's the part I was missing. After adding the scrollView to the cell contents, you need to use the UIPageControl (which didn't seem obvious to me for this implementation at first) to setup the actual "visual horizonal scrolling" affect:

   [[cell contentView] addSubview:scrollView];

pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 50, tv.frame.size.width, 50)];
[pageControl setNumberOfPages:4];
[[cell contentView] addSubview:pageControl];

希望對某人的搜索有所幫助 - 我在 Google 上花了很長時間尋找我剛剛解釋過的示例,但除了對其工作原理的一般概述之外沒有太多運氣.

Hope that helps someone's search - I spent quite some time on Google looking for the example I just explained and didn't have much luck other than the general overview of how it would work.

這篇關(guān)于UITableView 中的 UIScrollView 和 UIPageControl的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Stop a UITableView from automatically scrolling(阻止 UITableView 自動滾動)
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
UIImageView zoom and pinch in UIScrollView(UIImageView 在 UIScrollView 中縮放和捏合)
How can i add more than 10 buttons on a navigationbar in iphone application development?(如何在 iphone 應用程序開發(fā)中的導航欄上添加 10 多個按鈕?)
Using UITouch inside a UIScrollView(在 UIScrollView 中使用 UITouch)
主站蜘蛛池模板: 99热视| 雨宫琴音一区二区在线 | 成人夜晚看av | 999精品在线 | 妖精视频一区二区三区 | av高清 | 盗摄精品av一区二区三区 | 成人免费大片黄在线播放 | 国产精品久久久久久久久久久免费看 | 九九色综合 | 国产韩国精品一区二区三区 | 成人午夜激情 | 欧美日韩综合 | 日韩视频精品在线 | 最新免费av网站 | 成人精品一区二区三区中文字幕 | 亚洲欧美在线观看 | 噜啊噜在线 | 国产精品久久久久久久久免费软件 | 91视视频在线观看入口直接观看 | 久久久新视频 | 久久久久久网站 | 久久精品视频在线免费观看 | 亚洲一二三区免费 | 国产精品色av | 91就要激情 | 中文字幕亚洲精品 | 亚洲人成人一区二区在线观看 | 国产成人精品一区 | 欧美日韩国产欧美 | 日韩欧美理论片 | 欧美日韩在线免费 | 99精品在线 | 亚洲视频在线一区 | 69精品久久久久久 | 久久国产精品视频观看 | 国产综合久久 | 亚洲成av人片在线观看无码 | 欧美一级久久 | 日本在线免费 | 视频一区二区在线观看 |