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

如何在 UITableView 下方添加活動指示器?

How can i add a activity indicator below the UITableView?(如何在 UITableView 下方添加活動指示器?)
本文介紹了如何在 UITableView 下方添加活動指示器?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

在我的應用程序中,我想在 UItableview 下添加活動指示器,其中 tableview 將滾動,但我不知道如何在此處添加活動指示器.

In my application i want to add activity indicator under UItableview where tableview will scroll but i do not know how can i add activity indicator over there.

詳細說明,當我完成 tableview 的滾動時,對于更多數據,我必須通過活動指示器設置刷新選項.

To elaborate,when i will finish the scrolling of tableview then for more data i have to set a refresh option by an activity indicator.

我已經在 tableview 的頂部嘗試過它并且它有效,但我不知道如何將它添加到 tableview 下方.這是一些示例代碼..

i have tried it at the top of the tableview and it worked but i dont know how can i add it below the tableview. here is some sample code..

      - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
if (isLoading) return;
isDragging = YES;


refreshHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT, 320, REFRESH_HEADER_HEIGHT)];
refreshHeaderView.backgroundColor = [UIColor clearColor];

refreshLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT, 320, REFRESH_HEADER_HEIGHT)];
refreshLabel.backgroundColor = [UIColor clearColor];
refreshLabel.font = [UIFont boldSystemFontOfSize:12.0];
refreshLabel.textAlignment = UITextAlignmentCenter;

refreshArrow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"refresharrow.png"]];
refreshArrow.frame = CGRectMake((scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT - 27) / 2,
                                (scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT - 44) / 2,
                                27, 44);

refreshSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
refreshSpinner.frame = CGRectMake((scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT - 20) / 2, (scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT - 20) / 2, 20, 20);
refreshSpinner.hidesWhenStopped = YES;

[refreshHeaderView addSubview:refreshLabel];
[refreshHeaderView addSubview:refreshArrow];
[refreshHeaderView addSubview:refreshSpinner];
[tableview addSubview:refreshHeaderView];


}

 - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (isLoading) {
    // Update the content inset, good for section headers
    if (scrollView.contentOffset.y > 0){
        NSLog(@"scrollView.contentOffset.y 1= %d",scrollView.contentOffset.y );
        tableview.contentInset = UIEdgeInsetsZero;
    }
    else if (scrollView.contentOffset.y >= -REFRESH_HEADER_HEIGHT){
        NSLog(@"scrollView.contentOffset.y 2= %d",scrollView.contentOffset.y );
        tableview.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
    }
} else if (isDragging && scrollView.contentOffset.y > scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT) {
    // Update the arrow direction and label
    [UIView beginAnimations:nil context:NULL];
    if (scrollView.contentOffset.y > scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT) {
        // User is scrolling above the header
        NSLog(@"scrollView.contentOffset.y 3= %d",scrollView.contentOffset.y );
        refreshLabel.text = self.textRelease;
        [refreshArrow layer].transform = CATransform3DMakeRotation(M_PI, 0, 0, 1);
    } else { // User is scrolling somewhere within the header
        refreshLabel.text = self.textPull;
        [refreshArrow layer].transform = CATransform3DMakeRotation(M_PI * 2, 0, 0, 1);
    }
    [UIView commitAnimations];
}
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
if (isLoading) return;
isDragging = NO;
if (scrollView.contentOffset.y >= scrollView.contentOffset.y + REFRESH_HEADER_HEIGHT) {
    // Released above the header
    [self startLoading];
}
}

所以請有人給我一些示例代碼,說明我該怎么做.

so please someone give me some example code about how can i do that.

實際上我是 iphone 應用程序開發的新手.所以請幫助我.

actually i am new in iphone application development.So please help me.

提前致謝.

推薦答案

添加活動指示器的最佳方式是在tableview的頁腳.

The best way to add activity indicator is at footer of tableview.

    - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { 
UIView *headerView = [[[UIView alloc] init]autorelease];

    [headerView setBackgroundColor:[UIColor clearColor]];

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self 
? ? ? ? ? ?action:@selector(aMethod:)
?forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Load More" forState:UIControlStateNormal];
button.frame = CGRectMake(10.0, 210.0, 160.0, 40.0);


    [headerView addSubview:button];

    [headerLabel release];

    return headerView;

}  

向footerView 添加一個按鈕并將操作設置為按鈕(根據需要).這就是應用商店表格視圖的工作方式.點擊按鈕獲取更多數據添加到表格數組中滾動表格而不動畫.

Add a button to the footerView and set action to button (as you needed). This how app store tableview works. On clicking button fetch some more data add to table array scroll the table without animation.

這篇關于如何在 UITableView 下方添加活動指示器?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

UIButtons at the bottom of UIScrollView not working(UIScrollView 底部的 UIButtons 不起作用)
scrollViewWillEndDragging:withVelocity:targetContentOffset: not working on the edges of a UISCrollView(scrollViewWillEndDragging:withVelocity:targetContentOffset: 不在 UISCrollView 的邊緣工作) - IT屋-程序員軟件開發技術分享社
ImageView Scaling when scrolling down(向下滾動時 ImageView 縮放)
Bounds automatically changes on UIScrollView with content insets(UIScrollView 上的邊界自動更改,帶有內容插圖)
iOS5 UITapRecognizer for UIScrollView interfering with buttons. How to fix?(用于 UIScrollView 的 iOS5 UITapRecognizer 干擾按鈕.怎么修?)
How to Cancel Scrolling in UIScrollView(如何在 UIScrollView 中取消滾動)
主站蜘蛛池模板: 久久久久91 | 精品久久香蕉国产线看观看亚洲 | 天天玩天天干天天操 | 国产成视频在线观看 | 免费一级黄色 | 东京久久 | 精品久久久网站 | 五月天婷婷综合 | 2021狠狠干 | 久久久久国产一区二区三区四区 | 黄色小视频大全 | 日韩在线一区二区 | 999久久久久久久久6666 | 久久国产亚洲 | 国产午夜精品一区二区三区嫩草 | 日韩国产中文字幕 | 日韩精品一区二区三区 | 久久成人激情 | 爱综合| 亚洲一二三区在线观看 | 自拍 亚洲 欧美 老师 丝袜 | 91手机精品视频 | 一级全黄视频 | 97精品国产97久久久久久免费 | 91麻豆精品国产91久久久资源速度 | 日韩高清av | 男女精品网站 | 亚洲毛片 | 黄网免费看 | 天天夜碰日日摸日日澡 | 久久精品在线免费视频 | 日韩欧美在线免费观看 | 射久久 | 国产精品一区二区三区在线 | 色眯眯视频在线观看 | 在线国产一区二区 | 亚洲视频一区二区三区 | 欧美日韩专区 | zzzwww在线看片免费 | av一区二区三区四区 | 黄色免费在线观看 |