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

是否可以使用 UIPageControl 來控制 UITableView 的移動

Is that possible to use UIPageControl to control the move of UITableView?(是否可以使用 UIPageControl 來控制 UITableView 的移動?)
本文介紹了是否可以使用 UIPageControl 來控制 UITableView 的移動?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

從 Apple 示例PageControl"我們可以知道 UIPageControl 可用于控制頁面在滾動視圖中的移動.

From Apple sample "PageControl" we can know that UIPageControl can be used to control movement of pages in scrollview.

由于 UITableView 是 UIScrollView 的子類,我想使用 UIPageControl 來控制表格視圖單元格的移動,就像在PageControl"中一樣.

As UITableView is subclass of UIScrollView,I want to use UIPageControl to control the movement of table view cell just like in "PageControl".

但是找不到任何委托接口讓我這樣做.

But can not find any interface of delegate for me to do that.

問題是:

可以這樣做嗎?為什么?

謝謝

讓我回答我的問題:

以編程方式選擇和滾動

清單 6-5 以編程方式選擇行

Listing 6-5 Programmatically selecting a row

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath {
    NSIndexPath *scrollIndexPath;
    if (newIndexPath.row + 20 < [timeZoneNames count]) {
        scrollIndexPath = [NSIndexPath indexPathForRow:newIndexPath.row+20 inSection:newIndexPath.section];
    } else {
        scrollIndexPath = [NSIndexPath indexPathForRow:newIndexPath.row-20 inSection:newIndexPath.section];
    }
    [theTableView selectRowAtIndexPath:scrollIndexPath animated:YES
                        scrollPosition:UITableViewScrollPositionMiddle];
}

推薦答案

確實有可能,但你為什么想要這個?表格視圖垂直滾動,而頁面控件具有水平布局,因此它可能看起來/感覺很奇怪.

It sure is possible, but why would you want this? A table view scrolls vertically, while a page control has a horizontal layout, so it would probably look/feel weird.

無論如何,如果您真的想這樣做,請將您的視圖控制器添加為頁面控件的目標(biāo):

Anyway, if you really want to do this, add your view controller as a target of the page control:

[pageControl addTarget:self action:@selector(pageChanged:) forControlEvents:UIControlEventValueChanged];

然后在action中實現(xiàn)滾動:

Then implement the scrolling in the action:

- (void)pageChanged:(UIPageControl *)sender {
    float scrollPosition = ((float)sender.currentPage / (float)sender.numberOfPages) * tableView.contentSize.height;
    [tableView scrollRectToVisible:CGRectMake(0, scrollPosition, 1, 1) animated:YES];
}

這篇關(guān)于是否可以使用 UIPageControl 來控制 UITableView 的移動?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 延遲加載)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運行時,使用 iOS 6.0 SDK 并為 iOS 5 Target 構(gòu)建會導(dǎo)致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創(chuàng)建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
UIImageView zoom and pinch in UIScrollView(UIImageView 在 UIScrollView 中縮放和捏合)
主站蜘蛛池模板: 草草视频在线播放 | 黄色一级大片在线观看 | 国产美女一区二区 | 久久99精品久久久久久青青日本 | 成年人精品视频 | 日韩另类视频 | 欧美日韩不卡在线 | 黑人久久 | 亚洲精品女人久久久 | 久久极品 | 一区二区三区四区毛片 | 欧美日韩国产精品 | 国产精品一区二区在线播放 | 亚洲精品一二三区 | 国产精品国产精品 | 国产精品久久久久久高潮 | 永久免费视频 | 国产精品久久久久久久免费大片 | 成人一区二区三区在线观看 | 久久久观看 | 久久久精品一区二区三区 | 欧美日韩国产一区二区三区 | 日本三级黄视频 | 精品国产18久久久久久二百 | 国产激情一区二区三区 | 精品区 | 91精品国产综合久久精品 | 日韩欧美精品在线 | 羞羞涩涩在线观看 | 国产三级一区二区三区 | 久久成| 久久免费视频1 | 久久亚洲一区二区三区四区 | 欧美日韩精品中文字幕 | 国产一区二区不卡 | 天天综合久久 | 久久久91精品国产一区二区三区 | 国产成人99av超碰超爽 | 久久一区二区免费视频 | 欧美日一区 | 黑人巨大精品欧美一区二区免费 |