开发者

table view next results

开发者 https://www.devze.com 2023-01-10 06:05 出处:网络
How it is being implemented in开发者_如何学JAVA table view? To limit the results display in the table view, I need to display eg 10 results, then at the last part of the table cell there\'s the \"next

How it is being implemented in开发者_如何学JAVA table view? To limit the results display in the table view, I need to display eg 10 results, then at the last part of the table cell there's the "next results" part when selecting would load/insert the next set of data into the table view.

Pls. advise me. Thanks


You can make a 2 section UITableView...

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (indexPath.section == 0)
        return 10;
    else {
        return 1;
    }

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableView *cell;
    if (indexPath.section == 0)
        cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"normalCell"];
    else
        cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"nextCell"];

    if (!cell) {
        if (indexPath.section == 0)
            cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"normalCell"];
        else
            cell = [[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"nextCell"];
    }

    if (indexPath.section == 0) {
        // Set your normal cells
    } else {
        // Set your next cell
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        // your normal cells here
    } else {
        // your next cell here
    }

}

Of course this is not the only solution, but it works...

0

精彩评论

暂无评论...
验证码 换一张
取 消