QMUI / QMUI_iOS框架学习(三)

添加 QDUIKitViewController 继承自 QDCommonGridViewController并添加代码

- (void)initDataSource {
    self.dataSource = [[QMUIOrderedDictionary alloc] initWithKeysAndObjects:
                        @"QMUIButton", UIImageMake(@"icon_grid_button"),
                        @"QMUILabel", UIImageMake(@"icon_grid_label"),
                        @"QMUITextView", UIImageMake(@"icon_grid_textView"),
                        @"QMUITextField", UIImageMake(@"icon_grid_textField"),
                        @"QMUIAlertController", UIImageMake(@"icon_grid_alert"),
                        @"QMUITableViewCell", UIImageMake(@"icon_grid_cell"),
                        @"QMUICollectionViewLayout", UIImageMake(@"icon_grid_collection"),
                        @"QMUISearchController", UIImageMake(@"icon_grid_search"),
                        @"UINavigationController+QMUI", UIImageMake(@"icon_grid_navigation"),
                        @"UITabBarItem+QMUI", UIImageMake(@"icon_grid_tabBarItem"),
                        @"UIColor+QMUI", UIImageMake(@"icon_grid_color"),
                        @"UIImage+QMUI", UIImageMake(@"icon_grid_image"),
                        @"UIView+QMUI", UIImageMake(@"icon_grid_view"),
                        @"NSObject+QMUI", UIImageMake(@"icon_grid_nsobject"),
                        nil];
}


- (void)setNavigationItemsIsInEditMode:(BOOL)isInEditMode animated:(BOOL)animated {
    [super setNavigationItemsIsInEditMode:isInEditMode animated:animated];
    self.title = @"QMUIKit";
    self.navigationItem.rightBarButtonItem = [QMUINavigationButton barButtonItemWithImage:UIImageMake(@"icon_nav_about") position:QMUINavigationButtonPositionRight target:self action:@selector(handleAboutItemEvent)];
}

- (void)handleAboutItemEvent {

}

三段分别是数据源 – 导航栏 — 事件响应—-

这时候已经可以开始跑代码了

重写一下appdelegate

- (void)createTabBarController {
    QDTabBarViewController *tabBarViewController = [[QDTabBarViewController alloc] init];
    QDUIKitViewController *uikitViewController = [[QDUIKitViewController alloc] init];
    uikitViewController.hidesBottomBarWhenPushed = NO;
    QDNavigationController *uikitNavController = [[QDNavigationController alloc] initWithRootViewController:uikitViewController];
     tabBarViewController.viewControllers = @[uikitNavController];
    self.window.rootViewController = tabBarViewController;
    [self.window makeKeyAndVisible];
}

就可以了,看下跑起来的效果

QMUI / QMUI_iOS框架学习(三)_第1张图片

有点斜了,还需要后续处理

对比了一下官方demo,,原来官方demo就是斜的。。。蛋疼

找到了需要修改的地方

    //内容大小  宽度 =  自身的宽度 - 左右的边距    自身的高度 = 自身的宽度 - 上下的边距
    CGSize contentSize = CGSizeMake(CGRectGetWidth(self.bounds) - UIEdgeInsetsGetHorizontalValue(self.contentEdgeInsets),
                                    CGRectGetHeight(self.bounds) - UIEdgeInsetsGetVerticalValue(self.contentEdgeInsets));

原来是上下距离 写成 左右距离了,所以会出现这样的问题。发现给的demo里面很多这类的粗心错误,边写边帮他改正吧。

你可能感兴趣的:(QMUI / QMUI_iOS框架学习(三))