美文网首页
一个iOS项目总结点

一个iOS项目总结点

作者: 玉思盈蝶 | 来源:发表于2021-11-06 17:11 被阅读0次

之前一直用的Swift,回长沙做的第一个项目是OC。算是重新捡起OC的知识吧。

1、目前项目用到的一些第三方:

pod 'SDWebImage'
pod 'AFNetworking'
pod 'SVProgressHUD'
pod 'Toast'
pod 'YYKit'
pod 'MJRefresh'
pod 'MJExtension'
pod 'AAChartKit'
pod 'Masonry'
pod 'JXCategoryView'
pod 'BRPickerView'
pod 'AliyunOSSiOS'
pod 'SGQRCode', '~> 3.5.1'
#pod 'IQKeyboardManager'
pod 'DZNEmptyDataSet'
pod 'ZLCollectionViewFlowLayout'
pod 'JXBWebKit'
pod 'PinYin4Objc', '~> 1.1.1'
pod 'TPKeyboardAvoiding'

键盘处理一开始用的IQKeyboardManager,但是涉及到一个页面UITableViewCell都是输入框,导致点击输入框不自动马上响应(会先收起上一个响应的键盘,点第二次才会弹出键盘的问题),后面改用了TPKeyboardAvoiding。

2、UICollectionView不同的section的itemSize滑动会出现复用问题:
设置identifier解决。

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{    
    NSString *identifier=[NSString stringWithFormat:@"%ld%ld",(long)indexPath.section,(long)indexPath.row];
    [_collectionView registerClass:[CFClientStatusFilterCollectViewCell class] forCellWithReuseIdentifier:identifier];
    CFClientStatusFilterCollectViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
    
    cell.itemModel = [[self.dataArr objectAtIndex:indexPath.section].items objectAtIndex:indexPath.row];
    return cell;
}

3、身份证校验:

才知道直接校验15/18位数身份证验证是不精准的。
新的二代公民身份号码是特征组合码,由十七位数字本体码和一位校验码组成。排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位校验码。
https://www.jianshu.com/p/9405ced634ee

4、iOS 15适配:

if (@available(iOS 15.0, *)) {
        [UITableView appearance].sectionHeaderTopPadding = 0;
    }
// 设置导航主题
    if (@available(iOS 15.0, *)) {
        UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
//        [appearance configureWithOpaqueBackground];
        [[UINavigationBar appearance]setTintColor:UIColor.whiteColor];
        appearance.titleTextAttributes = textAt;
        [appearance setBackgroundImage:[UIImage imageWithColor:kCFMainColor]];
        [[UINavigationBar appearance] setScrollEdgeAppearance:appearance];
        [[UINavigationBar appearance] setStandardAppearance:appearance];
    } else {
        self.navigationBar.tintColor = [UIColor whiteColor];
        self.navigationBar.shadowImage = [[UIImage alloc] init];
        [self.navigationBar setBackgroundImage:[UIImage imageWithColor:kCFMainColor] forBarMetrics:UIBarMetricsDefault];
        [[UINavigationBar appearance] setTitleTextAttributes:textAt];
    }

目前是做了这两块的适配,其他没什么问题。

5、IQKeyboardManager不支持YYTextView和其他自定义TextView控件响应:

IQKeyboardManager不支持YYTextView的响应是因为没有监听YYTextView的自定义通知。
手动监听通知即可。

[[IQKeyboardManager sharedManager] registerTextFieldViewClass:[YYTextView class] didBeginEditingNotificationName:YYTextViewTextDidBeginEditingNotification didEndEditingNotificationName:YYTextViewTextDidEndEditingNotification];

不过项目最后也没用IQKeyboardManager管理键盘了。

6、UITableView行高问题:

大部分其实可以使用Masonry约束控件和UITableView的UITableViewAutomaticDimension实现,用了真的很方便呀。

其他的就直接根据Model内容自己算吧。

7、iPad横屏竖屏适配处理:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doRotateAction:) name:UIDeviceOrientationDidChangeNotification object:nil];
- (void)doRotateAction:(NSNotification *)notification {
    [self addChangeThePage];
}

-(void)addChangeThePage {
    if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait
        || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown) {
        self.collectionView.frame = self.collectionView.frame;
        self.isLandNo = NO;
    } else if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft
               || [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) {
        self.collectionView.frame = self.view.bounds;
        self.isLandNo = YES;
    }
}
-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    if (self.isLandNo) {
        self.collectionView.frame = self.view.bounds;
    }else{
        self.collectionView.frame = self.collectionView.frame;
    }
    dispatch_async(dispatch_get_main_queue(), ^{
        [self.collectionView reloadData];
    });
}

8、数据请求传值字典优化:

一开始我都是直接以下:

NSDictionary *params = @{
    @"name": self.todayToDoModel.name
}

改成下面可以防止控制闪退问题:

NSMutableDictionary *params =[[NSMutableDictionary alloc]init];
[params setValue:@"" forKey:@"name"];

9、UIPageViewController的使用:

实现Tab切换的content,可以使用UIPageViewController。

self.pageViewController = [[UIPageViewController alloc] initWithTransitionStyle:(UIPageViewControllerTransitionStyleScroll) navigationOrientation:(UIPageViewControllerNavigationOrientationHorizontal) options:nil];
self.pageViewController.delegate = self;
self.pageViewController.dataSource = self;

再然后实现切换代理即可。

10、图表第三方库:AAChartKit

11、tableView滚到指定位置:

一开始使用scrollToRow,但是不好用,顶部总差点,

[self.tableView scrollToRow:0 inSection:0 atScrollPosition:UITableViewScrollPositionTop animated:NO];

老老实实用setContentOffset吧,疑惑的是为啥scrollToRow为啥会差点。

[self.tableView setContentOffset:CGPointZero animated:NO];

PS:一部分总结吧,后面会更新哦~~~

相关文章

  • 一个iOS项目总结点

    之前一直用的Swift,回长沙做的第一个项目是OC。算是重新捡起OC的知识吧。 1、目前项目用到的一些第三方: 键...

  • 一个简单的UINavigationController和UITa

    iOS项目中总也少不了UITabBarController和UINavigationController,而且每次...

  • 2018-05-16

    目录 目录 iOS的一个小项目 项目描述 项目略解 iOS的一个小项目 项目描述 本项目是一个视图,是一个UIIm...

  • iOS项目中集成flutter

    创建iOS项目 这里我们先创建一个空的iOS项目来模拟已有的项目,取名叫iOS_demo 创建flutter模块 ...

  • iOS项目统计总代码行数

    打开终端,用cd命令 定位到工程所在的目录,然后调用以下命名即可把每个源代码文件行数及总数统计出来: 其中 -na...

  • iOS项目统计总代码行数

    最近公司申请软件著作权,需要统计总代码行数,亲测可用,所以写下来供广大农友参考: 步骤一: 打开终端,用cd命令 ...

  • iOS项目统计总代码行数

    最新公司需要把前端时间过的项目申请专利,需要我这边把项目代码量统计一下,第一时间找到Xcode插件管理工具Alca...

  • iOS项目统计总代码行数

    步骤一: 打开终端,用cd命令 定位到工程所在的目录,然后调用以下命名即可把每个源代码文件行数及总数统计出来: f...

  • iOS项目中接入Flutter

    官方文档 创建iOS项目 先创建一个空的iOS项目来模拟已有的项目,取名FlutterAdd。 创建Flutter...

  • iOS 如何优化项目

    iOS 如何优化项目 iOS 如何优化项目

网友评论

      本文标题:一个iOS项目总结点

      本文链接:https://www.haomeiwen.com/subject/nzujzltx.html