Coder Social home page Coder Social logo

Comments (2)

romaonthego avatar romaonthego commented on August 27, 2024

You need to implement a custom scrolling with a UITableView, which is always a pain and it won't feel native anyways.
I prefer to use UITableViewController in 99.9% of cases, here's how you can implement a toolbar with UITableViewController:

@interface ViewController

@property (strong, readwrite, nonatomic) UIView *topView;

@end

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
    self.topView.backgroundColor = [UIColor redColor];
    self.tableView.contentInset = UIEdgeInsetsMake(100, 0, 0, 0);
    self.tableView.scrollIndicatorInsets = self.tableView.contentInset;
    [self.view addSubview:self.topView];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGRect frame = self.topView.frame;
    frame.origin.y = scrollView.contentOffset.y;
    self.topView.frame = frame;

    [scrollView bringSubviewToFront:self.topView];
}

and a bottom bar:

- (void)viewDidLoad
{
    self.bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 144, 320, 100)]; // 144: 100 + navigationbar height
    self.bottomView.backgroundColor = [UIColor redColor];
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 100, 0); // Adjust content inset to accommodate bottom edge inset
    self.tableView.scrollIndicatorInsets = self.tableView.contentInset;
    [self.view addSubview:self.bottomView];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGRect frame = self.bottomView.frame;
    frame.origin.y = scrollView.contentOffset.y + scrollView.frame.size.height - 100; // Move view to the bottom on scroll
    self.bottomView.frame = frame;
    [scrollView bringSubviewToFront:self.bottomView];
}

from retableviewmanager.

shmidt avatar shmidt commented on August 27, 2024

Thanks for sharing :). Works perfect!

from retableviewmanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.