项目一(电影APP)——iOS学习连载26

1. 删除系统的tabbarItem
NSArray *array = self.tabBar.subviews;
//注意:UITabBarButton是一个私有的API,没有公开出来
//遍历tabbar中所有的子视图,并且移除tabbarItem
for (UIView *view in array) {
    Class cls = NSClassFromString(@"UITabBarButton");
    if ([view isKindOfClass: cls]) {
     //移除tabbar上的按钮
     [view removeFromSuperview];
     }
2. 动画修改选择视图的坐标
  [UIView animateWithDuration:0.3
                     animations:^{
                   _selectedImgView.center = item.center;
                     }];
3. 第一次添加到控制器视图上的子视图如果是ScrollView的对象(包含ScrollView子类的对象),则视图的内容偏移量会根据是否有导航栏和标签栏进行扩充
4. 配置翻转动画(此方法与下面方法比较需要去求得翻转图片的下标)
        [UIView transitionWithView:imgView
                          duration:0.5
                           options:UIViewAnimationOptionTransitionFlipFromLeft
                       
animations:^{
                            [
self.view exchangeSubviewAtIndex:index1 withSubviewAtIndex:index2];
                        }
                        completion:nil];
5.翻转forView的两个子视图(forView:需要被翻转视图的父视图;flag:是否从左往右翻转)
//翻转视图
[self flipView:self.view left:btn1.hidden];

- (void)flipView:(UIView *)forView left:(BOOL)flag
{
   
UIViewAnimationOptions flip;
   
if(flag)
    {
      flip = UIViewAnimationOptionTransitionFlipFromLeft;
    }
   
else
    {
     flip = UIViewAnimationOptionTransitionFlipFromRight;
    }
   
   
//翻转
    [
UIView transitionWithView:forView duration:0.5 options:flip animations:^{
       
    }
completion:nil];
}
6.iOS5.0之前解析json数据 ——> 使用第三方json解析工具: jsonKit/TouchJson/SBJson
  iOS5.0之后 ——> 使用NSJSONSerialization解析
7. //找到json数据路径
NSString *filePath = [[NSBundle mainBundle] pathForResource:us_box ofType:@"json"];
//从文件路径中获取数据
NSData *data = [NSData dataWithContentsOfFile:filePath];
//解析json----》转换成NSDictionary或者是NSArray
NSError *error = nil;
NSDictionary *jsonDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
8. //拿到图片地址
NSString *urlStr = [self.movie.images objectForKey:@"medium"];
//构建URL方法一
NSURL *imgurl = [NSURL URLWithString:urlStr];
[_imgView sd_setImageWithURL:imgurl];
//构建URL方法二
NSURL *imgurl = [NSURL URLWithString:urlStr];
NSData *data = [NSData dataWithContentsOfURL:imgurl];
self.imageView.image = [UIImage imageWithData:data];
9. 当视图修改了transform后,坐标会变,需要重新恢复坐标
     CGPointMake(0, 0)CGPointZero等效
10.只要改变数据源,就要刷新tableView
11. 隐藏状态栏
- (BOOL)prefersStatusBarHidden
{
   
return self.navigationController.navigationBarHidden;
}

- (
UIStatusBarAnimation)preferredStatusBarUpdateAnimation
{
   
return UIStatusBarAnimationFade;
}
12. view =  layer + 事件接收
13. 设置边框宽度
  userImage.layer.borderWidth = 1;
 //设置边框颜色
  userImage.layer.borderColor = [UIColor whiteColor].CGColor;
14. 把头像设置为圆形, 设置圆角半径
    userImage.layer.cornerRadius = 27;//27为正方形图片边长的一半)
    userImage.layer.masksToBounds = YES; //剪切多余部分
15.把图片的宽从0、高从10像素开始画,直到填充整个imgview,可以避免图片拉伸
   UIImage *img = [ImgView.imagestretchableImageWithLeftCapWidth:0topCapHeight:10];
    ImgView.image = img;
 16./****判断是否是第一次启动,用于设置第一次启动的启动页面****/
    //获取沙盒目录
   
NSString *filePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/wx47.plist"];
   
//区分第一次启动还是以后启动的
   
NSDictionary *dic = [NSDictionary dictionaryWithContentsOfFile:filePath];
   
if (dic == nil) {
       
//第一次运行
        [
self _initFirstOpenView];
        dic =
@{@"first": @"YES"};
       
//把一个字典写入到文件
        [dic
writeToFile:filePath atomically:YES];
    }
17.清除缓存
- (void)_countCacheSize
{
   
//获取应用程序的沙盒路径
   
NSString *homePath = NSHomeDirectory();
//    NSLog(@"homePath is %@", homePath);
   
   
//拼接出缓存路径
   
NSString *imgPath = [homePath stringByAppendingPathComponent:@"Library/Caches/default/com.hackemist.SDWebImageCache.default"];
   
   
//文件管理助手(管家)---->单利对象
   
NSFileManager *fileManager = [NSFileManager defaultManager];
   
   
//取得一个文件夹下所有的文件路径
   
NSError *error = nil;
    NSArray *subPath = [fileManager subpathsOfDirectoryAtPath:imgPath error:&error];
   
   
long long sum = 0;
   
   
for (NSString *filePath in subPath) {
       
//取得一个文件的路径
       
NSString *path = [imgPath stringByAppendingPathComponent:filePath];
       
       
//拿到文件的属性
       
NSDictionary *attributes = [fileManager attributesOfItemAtPath:path error:&error];
       
       
//取出文件的大小
       
NSNumber *filesize = attributes[NSFileSize];
       
        sum += [filesize
longLongValue];
       
    }
   
   
cacheSize = sum / (1000.0 * 1000);
   
NSLog(@"cacheSize is %.2f", cacheSize);
   
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
   
if (indexPath.row == 0) {
        [
self _countCacheSize];
       
UILabel *label = (UILabel *)[cell viewWithTag:100];
        label.
text = [NSString stringWithFormat:@"%.1fM", cacheSize];
    }
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
   
if (indexPath.row == 0) {
       
//弹出清除对话框
       
UIAlertController *alertCtrl = [UIAlertController alertControllerWithTitle:@"清空缓存" message:@"确定要清空缓存" preferredStyle:UIAlertControllerStyleAlert];
       
       
UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
       
       
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
           
//确定清空缓存
            [[SDImageCache sharedImageCache] clearDisk];
           
           
//刷新tableView
            [
self.tableView reloadData];
           
        }];
       
        [alertCtrl
addAction:cancleAction];
        [alertCtrl
addAction:sureAction];
        [
self presentViewController:alertCtrl animated:YES completion:nil];
    }
}
- (void)viewWillAppear:(BOOL)animated
{
    [
super viewWillAppear:animated];
   
//刷新tableView
    [
self.tableView reloadData];
}
18.label宽度自适应
- (CGSize)labelAutoCalculateRectWith:(NSString*)text FontSize:(CGFloat)fontSize MaxSize:(CGSize)maxSize
{
   
   
NSMutableParagraphStyle* paragraphStyle = [[NSMutableParagraphStyle alloc]init];
   
    paragraphStyle.
lineBreakMode = NSLineBreakByWordWrapping;
   
   
NSDictionary* attributes =@{NSFontAttributeName:[UIFont systemFontOfSize:fontSize],NSParagraphStyleAttributeName:paragraphStyle.copy};
   
   
CGSize labelSize = [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading | NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;
   
    labelSize.
height = ceil(labelSize.height);
   
    labelSize.
width = ceil(labelSize.width);
   
   
return labelSize;
   
}
潮汐研究作为海洋科学的关键分支,融合了物理海洋学、地理信息系统及水利工程等多领域知识。TMD2.05.zip是套基于MATLAB环境开发的潮汐专用分析工具集,为科研人员与工程实践者提供系统化的潮汐建模与计算支持。该工具箱通过模块化设计实现了两大核心功能: 在交互界面设计方面,工具箱构建了图形化操作环境,有效降低了非专业用户的操作门槛。通过预设参数输入模块(涵盖地理坐标、时间序列、测站数据等),用户可自主配置模型运行条件。界面集成数据加载、参数调整、可视化呈现及流程控制等标准化组件,将复杂的数值运算过程转化为可交互的操作流程。 在潮汐预测模块中,工具箱整合了谐波分解法与潮流要素解析法等数学模型。这些算法能够解构潮汐观测数据,识别关键影响要素(包括K1、O1、M2等核心分潮),并生成不同时间尺度的潮汐预报。基于这些模型,研究者可精准推算特定海域的潮位变化周期与振幅特征,为海洋工程建设、港湾规划设计及海洋生态研究提供定量依据。 该工具集在实践中的应用方向包括: - **潮汐动力解析**:通过多站点观测数据比对,揭示区域主导潮汐成分的时空分布规律 - **数值模型构建**:基于历史观测序列建立潮汐动力学模型,实现潮汐现象的数字化重构与预测 - **工程影响量化**:在海岸开发项目中评估人工构筑物对自然潮汐节律的扰动效应 - **极端事件模拟**:建立风暴潮与天文潮耦合模型,提升海洋灾害预警的时空精度 工具箱以"TMD"为主程序包,内含完整的函数库与示例脚本。用户部署后可通过MATLAB平台调用相关模块,参照技术文档完成全流程操作。这套工具集将专业计算能力与人性化操作界面有机结合,形成了从数据输入到成果输出的完整研究链条,显著提升了潮汐研究的工程适用性与科研效率。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值