• 第三方MBXPageViewController的使用和注意事项


    GitHub的地址: https://github.com/Moblox/MBXPageViewController

    介绍SegmentController的使用:

    - (void)createSegmentView {
        
        CGFloat segmentX = (K_SCREEN_WIDTH - 150)/2;
        CGFloat topHeight = 40.f;
        CGFloat segmentY = (topHeight - K_SEGMENTED_CONTROL_HEIGHT) * 0.5 + 20;
        CGFloat segmentWidth = 200;
        UISegmentedControl *segmentControl = [[UISegmentedControl alloc] initWithItems:@[@"申请信息",@"审批操作"]];
        segmentControl.frame = CGRectMake(segmentX, segmentY, segmentWidth, K_SEGMENTED_CONTROL_HEIGHT);
        segmentControl.selectedSegmentIndex = 0;
        segmentControl.tintColor = MAIN_COLOR;
        [self.view addSubview:segmentControl];
        self.segmentControl = segmentControl;
        
        UIView *containerView = [[UIView alloc] initWithFrame:CGRectMake(0, topHeight + 20, K_SCREEN_WIDTH, K_SCREEN_HEIGHT - K_STATUS_BAR_AND_NAVI_BAR_HEIGHT - topHeight)];
        [self.view addSubview:containerView];
        self.containerView = containerView;
        
        self.MBXPageController = [MBXPageViewController new];
        self.MBXPageController.MBXDataSource = self;
        self.MBXPageController.MBXDataDelegate = self;
        self.MBXPageController.pageMode = MBX_SegmentController;
        [self.MBXPageController reloadPages];
        [self MBXPageChangedToIndex:0];
    }

    代理使用如下:

    #pragma mark - MBXPageViewController Data Source
    
    - (NSArray *)MBXPageButtons {
        return @[self.segmentControl];
    }
    
    - (UIView *)MBXPageContainer {
        return self.containerView;
    }
    
    // 给控制器传递数据在此代理写!!!
    - (NSArray *)MBXPageControllers { ApplyInfoViewController *appVc = [ApplyInfoViewController new]; appVc.idString = self.model.idString; RepairCheckViewController *checkVc = [RepairCheckViewController new]; checkVc.idString2 = self.model.idString; return @[appVc, checkVc]; } #pragma mark - MBXPageViewController Delegate
    // 给控制器传递数据不能再这里写!!!否则不能刷新表视图!!! - (void)MBXPageChangedToIndex:(NSInteger)index { // if (index == 0) { // NSLog(@"111"); // ApplyInfoViewController *applyInfoVc = self.MBXPageControllers[0]; // [self.containerView addSubview:applyInfoVc.view]; // applyInfoVc.idString = self.model.idString; //// applyInfoVc.model = self.model; // } // else { // NSLog(@"222"); // RepairCheckViewController *checkVc = self.MBXPageControllers[1]; // [self.containerView addSubview:checkVc.view]; // checkVc.idString2 = self.model.idString; //// checkVc.model = self.model; // } }

    总结:

    1.表视图cellForRow不执行的原因如下几种:

    1>.dataSource和delegate没有设置

    2>.numberOfRowsInSection和numberOfRowsInSection返回的数据不是大于0的整数

    3>.tableView没有添加到父视图上(这种情况,第2点种的方法都执行了)

    2.使用第三方框架的时候一定要先熟悉使用方法,不然会在使用上浪费很多时间.

    花了一天的时间找问题,很高兴最后还是找到问题所在了,还是学到了点东东.....好开心,加油!!! 

  • 相关阅读:
    POJ1521 最优哈夫曼编码树 贪心算法的有效应用
    hdu4911逆序对+mergesort
    hdu1735 字数统计 贪心算法
    最大不相交区间数+最少区间数覆盖问题 贪心思想
    洛谷1010 幂次方 分治算法+掩码的应用
    POJ 2082 三种解法(暴力+树状数组+线段树)
    POJ3134 Power Calculus IDA*搜索的一个应用
    hdu2648 STL map的简单应用
    Delphi 数据类型与Windows 数据类型 对照
    Delphi Window Messages 消息
  • 原文地址:https://www.cnblogs.com/pengsi/p/6394883.html
Copyright © 2020-2023  润新知