IOS开发日记
来源:互联网 发布:开淘宝网店难吗 编辑:程序博客网 时间:2024/06/04 18:47
2016.07.19
- UILabel 在宽度固定的情况下,设置其根据文字长度调整字体:
@property (weak, nonatomic) IBOutlet UILabel *pinyName;self.pinyName.adjustsFontSizeToFitWidth = YES;
- 弹出框
IOS 9.0 以前:
NSString *msg = @"something";UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:msg delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];[alert show];
IOS 9.0 以后:
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"something" preferredStyle:UIAlertControllerStyleAlert];[alertController addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { // 响应事件}]];[self presentViewController:alertController animated:YES completion:nil];
2016.07.20
- 根据内容调整UIView大小
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"psnChangeCell"];UILabel *textView = (UILabel *)[cell viewWithTag:17];textView.text = rowRecord.msg;CGSize s = [textView sizeThatFits:CGSizeMake([UIScreen mainScreen].bounds.size.width - 74, FLT_MAX)];
- 从 storyboard 中加载 view controller 并显示
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)let registerViewController = mainStoryboard.instantiateViewControllerWithIdentifier("registerViewController")self.presentViewController(registerViewController, animated: false, completion: nil)
- 使 UITextField 弹出的键盘为数字键盘
self.resultTextField.keyboardType = .NumberPad
2016.07.22
- 禁止 UITableViewCell 向左滑动时显示删除按钮
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewCellEditingStyleNone;}
2016.07.26
- 自定义导航栏的标题
// 设置自定义标题栏,避免标题过长,返回按钮被遮盖的问题UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 40)];UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];[titleLabel setFont:[UIFont systemFontOfSize:17.0 weight:UIFontWeightMedium]];[titleLabel setTextColor:[UIColor whiteColor]];[titleLabel setCenter:titleView.center];[titleLabel setTextAlignment:NSTextAlignmentCenter];[titleLabel setAdjustsFontSizeToFitWidth:YES];[titleView addSubview:titleLabel];[self.navigationItem setTitleView:titleView];[titleLabel setText:self.title];self.titleLabel = titleLabel;
- 去除UITableView底部多余的分割线
- (void)viewDidLoad{ [super viewDidLoad]; self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];}
2016.07.29
- Observer模式应用
// 添加Observer[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadFCL) name:@"reloadFCL" object:nil];// 删除Observer- (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self];}// 发送消息,userInfo是一个Dictionary[[NSNotificationCenter defaultCenter] postNotificationName:@"reloadFCL" object:nil userInfo:nil];
- 屏蔽手势滑动返回功能
- (void)viewWillAppear:(BOOL)animated{ // 屏蔽手势返回功能 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO; }}- (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:YES]; // 开启手势返回功能 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = YES; }}
2016.08.02
- 设置UILabel当text过长时以省略号结尾
[titleLabel setLineBreakMode:NSLineBreakByTruncatingTail];
2016.08.03
- 隐藏导航栏
[self.navigationController setNavigationBarHidden:YES];
2016.08.04
- 隐藏UIViewController底部导航栏
[controller setHidesBottomBarWhenPushed:YES];[self.navigationController pushViewController:controller animated:YES];
2016.08.24
- 隐藏系统状态栏,顶部带电池的那个栏
- (BOOL)prefersStatusBarHidden { return YES;}
- 显示等待窗口
// 定义 indicatorView 和 indicatorLabel@property (strong, nonatomic) UIActivityIndicatorView* indicatorView;@property (strong, nonatomic) UILabel* indicatorLabel;// 初始化self.indicatorView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];self.indicatorView.center = self.view.center;self.indicatorView.frame = self.view.frame;self.indicatorView.backgroundColor = [UIColor blackColor];self.indicatorView.alpha = 0.75;self.indicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;[self.view addSubview:self.indicatorView];self.indicatorLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 250, 30)];self.indicatorLabel.textColor = [UIColor whiteColor];self.indicatorLabel.textAlignment = NSTextAlignmentCenter;self.indicatorLabel.text = @"正在加载会议列表,请稍候...";self.indicatorLabel.center = CGPointMake(self.view.center.x, self.view.center.y + 40);[self.view addSubview:self.indicatorLabel];// 显示&隐藏[self.indicatorView startAnimating];self.indicatorLabel.hidden = NO;
2016.09.08
- URL打开app
- 首先被启动的应用需要向iPhone注册一个自定义URL协议。这是在你的项目文件夹的info.plist文件进行的(就是你改变应用程序图标的同一个文件)。
- 右键,选择“Add Row”
- Key值选择“URL types”
- 打开“Item 0″,然后为该key增加一个URL identifier。可以是任何值,但建议用“反域名”(例如 “com.cynhard.LinphoneTest”)。
- 在“Item 0”下再加一行。
- 选择“URL Schemes” 作为Key。
- 输入你的URL协议名 (例如“testHello://” 应写做“testHello”)。如果有必要,你可以在这里加入多个协议。
- 访问URL:
<!DOCTYPE html><html> <head> <title>Hello World</title> </head> <body> <a href="LinphoneTest://">test</a> </body></html>
2016.09.09
- 使用lipo命令合成静态库
lipo -create Release-iphoneos/libMyToolsA.a Release-iphonesimulator/libMyToolsA.a -output libMyToolsA.a
- 查看库的信息
lipo -info libMyToolsA.a
0 0
- iOS开发日记
- IOS开发日记
- iOS开发之Block日记
- 开发日记
- 开发日记
- 开发日记
- 开发日记
- 开发日记
- 小白IOS开发日记-UITableView篇(一)
- iOS开发日记23-Xcode生成API文档(HeaderDoc)
- iOS开发日记55-隐式与显式动画
- iOS开发日记第二弹 程序内截屏,毛玻璃效果!
- IOS学习日记1
- ios学习日记
- ios-label-字体大小-日记
- IOS学习日记
- ios-日记1
- iOS个人学习日记
- 任志强内部又放话:2017房价会比这一轮涨得更高!
- struct
- Beyond Compare 相同文件对比结果仍显示红色 解决方案
- Leetcode 207. Course Schedule
- 数据缓存机制
- IOS开发日记
- 机器学习的理解
- virtualenv安装并配置flask开发环境
- 通过JS语句判断WEB网站的访问端是电脑还是手机
- 论文笔记: Hierarchical Question-Image Co-Attention for Visual Question Answering
- Mabitis中#与$符号区别
- 中国质造代办
- 【Hibernate】lazy延迟加载
- php使用淘宝IP库接口获取 IP所属地和运营商