第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

UITableView無限滾動(dòng)

UITableView無限滾動(dòng)

慕慕森 2019-12-17 10:43:24
如何在中無限滾動(dòng)UITableView?我知道如何使用來完成此操作UIScrollView,其中WWDC的視頻中已經(jīng)演示了蘋果。我嘗試在執(zhí)行以下操作tableView:cellForRowAtIndexPath::if (indexPath.row == [self.newsFeedData_ count] - 1){    [self.newsFeedData_ addObjectsFromArray:self.newsFeedData_];    [self.tableView reloadData];}但這失敗了。還有其他想法嗎?
查看完整描述

3 回答

?
MMMHUHU

TA貢獻(xiàn)1834條經(jīng)驗(yàn) 獲得超8個(gè)贊

如果您需要知道何時(shí)到達(dá)UITableView的底部,請成為它的委托(因?yàn)樗荱IScrollView的子類),然后使用-scrollViewDidScroll:委托方法比較表的內(nèi)容高度和實(shí)際滾動(dòng)位置。


編輯(類似這樣):


- (void)scrollViewDidScroll:(UIScrollView *)scrollView_ 

{   

    CGFloat actualPosition = scrollView_.contentOffset.y;

    CGFloat contentHeight = scrollView_.contentSize.height - (someArbitraryNumber);

    if (actualPosition >= contentHeight) {

        [self.newsFeedData_ addObjectsFromArray:self.newsFeedData_];

        [self.tableView reloadData];

     }

}


查看完整回答
反對 回復(fù) 2019-12-17
?
偶然的你

TA貢獻(xiàn)1841條經(jīng)驗(yàn) 獲得超3個(gè)贊

這是我放在一起的無限滾動(dòng)UITableView的非??焖俸屯暾难菔?..


@interface InfiniteScrollViewController ()


@property (nonatomic) NSMutableArray *tableViewData;

@property (nonatomic) BOOL loadingMoreTableViewData;


@end


@implementation InfiniteScrollViewController


- (void)viewDidLoad {

    self.tableViewData = [[NSMutableArray alloc] init];

    [self addSomeMoreEntriesToTableView];

}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return self.tableViewData.count + 1;

}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    }


    if (indexPath.row < self.tableViewData.count) {

        cell.textLabel.text = [self.tableViewData objectAtIndex:indexPath.row];

    } else {

        cell.textLabel.text = @"Loading more data...";


        // User has scrolled to the bottom of the list of available data so simulate loading some more if we aren't already

        if (!self.loadingMoreTableViewData) {

            self.loadingMoreTableViewData = YES;

            [self performSelector:@selector(addSomeMoreEntriesToTableView) withObject:nil afterDelay:5.0f];

        }

    }


    return cell;

}


- (void)addSomeMoreEntriesToTableView {

    int loopTill = self.tableViewData.count + 20;

    while (self.tableViewData.count < loopTill) {

        [self.tableViewData addObject:[NSString stringWithFormat:@"%i", self.tableViewData.count]];

    };

    self.loadingMoreTableViewData = NO;

    [self.tableView reloadData];

}


@end


查看完整回答
反對 回復(fù) 2019-12-17
  • 3 回答
  • 0 關(guān)注
  • 806 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號