Ios-hqsliderview Click on different button switch Tableviewcell

Source: Internet
Author: User

Effect:
The code is as follows Copy Code
1. The Custom click button toggles the different Tableviewcell, the effect as shown in the picture

Hqsliderview.gif
Use tutorials:
The code is as follows Copy Code
2.1 Import Hqsliderview

Copy Hqsliderview to project. png
The code is as follows Copy Code
2.2 Viewdidload Method inside
- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];

    [self setupTopSliderView];
    [self setupTableView];
}
The code is as follows Copy Code
2.3 Create Upper Sliderview
#pragma mark - 创建上部SliderView
- (void)setupTopSliderView
{
    HQSliderView *sliderView = [[HQSliderView alloc] initWithFrame:CGRectMake(0, NAV_HEIGHT, SCREEN_WIDTH, SLIDER_HEIGHT)];
    sliderView.titleArr = @[@"全部", @"待付款", @"已付款", @"退款"];
    sliderView.delegate = self;
    [self.view addSubview:sliderView];
}
The code is as follows Copy Code
2.4 Creating TableView
#pragma mark - 创建TableView
- (void)setupTableView
{
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NAV_HEIGHT + SLIDER_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT - NAV_HEIGHT)];
    tableView.dataSource = self;
    [self.view addSubview:tableView];
    self.tableView = tableView;
}
  code is as follows copy code
2.5 implementing TableView Data source Method
#pragma mark-uitableviewdatasource-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (NSInteger
    ) Section {if (Self.menutag = 0) {return 3;
    else if (Self.menutag = = 1) {return 6;
    else if (Self.menutag = = 2) {return 9;
    else {return 12; }-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) IndexPath {HQTableV

    Iewcell *cell = [Hqtableviewcell Tableviewcellwithtableview:tableview];
    if (Self.menutag = = 0) {Cell.textLabel.text = [nsstring stringwithformat:@ "All---%ld rows", Indexpath.row]; 
    else if (Self.menutag = 1) {cell.textLabel.text = [nsstring stringwithformat:@ "pending Payment---%ld rows", Indexpath.row]; else if (Self.menutag = 2) {cell.textLabel.text = [nsstring stringwithformat:@ ' Paid---%ld rows ', Indexpath.
    Row];
    else {cell.textLabel.text = [nsstring stringwithformat:@ "Refund---%ld rows", Indexpath.row];

   } return cell; }
The code is as follows Copy Code
2.6 Proxy method to implement Hqsliderview
#pragma mark - HQSliderViewDelegate
- (void)sliderView:(HQSliderView *)sliderView didClickMenuButton:(UIButton *)button
{
    self.menuTag = button.tag;
    [self.tableView reloadData];
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.