一. 前言

平时在处理问题的时候,经常会遇到一些奇奇怪怪的问题,今天在这里将其记录下来。这里将会列举几个常用的UI问题进行讲解

二. 导航栏

iOS导航栏绝对是个巨坑。和很多朋友聊天都是自己实现了一套导航栏。当然,我个人是比较推崇用系统的方法。因为好处好几个:1.新特性推出之后简单易改 2.代码安装包体积的问题

1. 导航栏、状态栏的显示与隐藏

一般直接用系统的导航栏状态栏我们会这么做,优点:使用简单方便

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated]; //恢复导航栏和状态栏
[self.navigationController setNavigationBarHidden:NO animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
} - (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated]; //隐藏导航栏和状态栏
[self.navigationController setNavigationBarHidden:YES animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
- (BOOL)prefersStatusBarHidden
{
return YES;
}

2. 自定义导航栏

三. 键盘

UITableView上的键盘隐藏与弹起
以前碰到网上的代码实属坑,弹出的时候还有延时。凡事还是得自己动手试一试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
-(void)registerNotifications
{
//注册通知
CZ_AddObj2DeftNotiCenter(self, @selector(keyboardWillShow:), UIKeyboardWillShowNotification, nil);
CZ_AddObj2DeftNotiCenter(self, @selector(keyboardWillHide:), UIKeyboardWillHideNotification, nil);
}
#pragma mark- TableView
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
#pragma mark- keyboard
- (void)keyboardWillShow:(NSNotification*)notification
{
NSDictionary* info = [notification userInfo];
CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
// NSInteger curve = [notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];
// NSTimeInterval duration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]; CGRect oldFram = self.cardDetailTableView.frame;
self.cardDetailTableView.frame = CGRectMake(oldFram.origin.x,- kbSize.height, oldFram.size.width, oldFram.size.height); UIEdgeInsets contentInsets = UIEdgeInsetsMake(kbSize.height, 0.0, 0.0, 0.0);
self.cardDetailTableView.contentInset = contentInsets;
self.cardDetailTableView.scrollIndicatorInsets = contentInsets; if(_tableRecognizer) {
[_cardDetailTableView removeGestureRecognizer:_tableRecognizer];
}
_tableRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
_tableRecognizer.numberOfTapsRequired = 1;
[_cardDetailTableView addGestureRecognizer:_tableRecognizer];
} - (void)keyboardWillHide:(NSNotification *)notification
{
// NSDictionary* info = [notification userInfo];
CGRect oldFram = self.cardDetailTableView.frame;
self.cardDetailTableView.frame = CGRectMake(oldFram.origin.x, 0.0, oldFram.size.width, oldFram.size.height);
self.cardDetailTableView.contentInset = UIEdgeInsetsZero;
self.cardDetailTableView.scrollIndicatorInsets = UIEdgeInsetsZero;
} - (void)hideKeyboard
{
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) to:nil from:nil forEvent:nil];
if(_tableRecognizer) {
_tableRecognizer.delegate = nil;
[_cardDetailTableView removeGestureRecognizer:_tableRecognizer];
}
}

实战荟萃-UI篇的更多相关文章

  1. iOS进阶指南试读之UI篇

    iOS进阶指南试读之UI篇 UI篇 UI是一个iOS开发工程师的基本功.怎么说?UI本质上就是你调用苹果提供给你的API来完成设计师的设计.所以,想提升UI的功力也很简单,没事就看看UIKit里的各个 ...

  2. iOS开发UI篇—CAlayer(自定义layer)

    iOS开发UI篇—CAlayer(自定义layer) 一.第一种方式 1.简单说明 以前想要在view中画东西,需要自定义view,创建一个类与之关联,让这个类继承自UIView,然后重写它的Draw ...

  3. iOS开发UI篇—UITabBarController简单介绍

    iOS开发UI篇—UITabBarController简单介绍 一.简单介绍 UITabBarController和UINavigationController类似,UITabBarControlle ...

  4. iOS开发UI篇—懒加载

    iOS开发UI篇—懒加载 1.懒加载基本 懒加载——也称为延迟加载,即在需要的时候才加载(效率低,占用内存小).所谓懒加载,写的是其get方法. 注意:如果是懒加载的话则一定要注意先判断是否已经有了, ...

  5. iOS开发UI篇—CAlayer层的属性

    iOS开发UI篇—CAlayer层的属性 一.position和anchorPoint 1.简单介绍 CALayer有2个非常重要的属性:position和anchorPoint @property ...

  6. iOS开发UI篇—CAlayer(创建图层)

    iOS开发UI篇—CAlayer(创建图层) 一.添加一个图层 添加图层的步骤: 1.创建layer 2.设置layer的属性(设置了颜色,bounds才能显示出来) 3.将layer添加到界面上(控 ...

  7. iOS开发UI篇—CALayer简介

    iOS开发UI篇—CALayer简介   一.简单介绍 在iOS中,你能看得见摸得着的东西基本上都是UIView,比如一个按钮.一个文本标签.一个文本输入框.一个图标等等,这些都是UIView. 其实 ...

  8. iOS开发UI篇—核心动画(UIView封装动画)

    iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...

  9. iOS开发UI篇—核心动画(转场动画和组动画)

    转自:http://www.cnblogs.com/wendingding/p/3801454.html iOS开发UI篇—核心动画(转场动画和组动画) 一.转场动画简单介绍 CAAnimation的 ...

随机推荐

  1. 转载:JavaScript多线程编程简介

    虽然有越来越多的网站在应用AJAX技术进行开发,但是构建一个复杂的AJAX应用仍然是一个难题.造成这些困难的主要原因是什么呢?是与服务器的异步通信问题?还是GUI程序设计问题呢?通常这两项工作都是由桌 ...

  2. squid和varnish的小结

    squid和varnish的小结 http://blog.haohtml.com/     上周初步接触linux下的这2个反向缓存软件,都实验了一下,貌似squid还是比较顺利的,varnish则碰 ...

  3. 两个80c51单片机之间怎样进行串行通信

    以前以为串行通信只能是单片机和PC机之间进行通信,昨天无意之中看到一个程序,是单片机和单片机之间进行通信..这小东西真是神奇啊!昨天弄了很长时间没弄出来,今天在大神的帮助下终于拨开云雾见天日了. 案例 ...

  4. 最小包围多边形(凸包;最小包围点集)——C代码例子

    本文来自:http://alienryderflex.com/smallest_enclosing_polygon/ 这个C代码例子需要一群2维点集,如下图所示: 要获得包含这些点的最小多边形如下图所 ...

  5. hdu 1998 奇数阶魔方(找规律+模拟)

    应该不算太水吧. 17  24   1   8  15   23   5   7  14  16    4   6  13  20  22   10  12  19  21   3   11  18 ...

  6. JS 处理十六进制颜色渐变算法-输入颜色,输出渐变rgb数组

    html颜色有几种表示方式: 英文单词颜色值:background-color:Blue:十六进制颜色值:background-color:#FFFFFF:  RGB颜色值三元数字:backgroun ...

  7. Android便携式热点的开启状态检测和SSID的获取

    WIFI热点的开启状态和开启后的SSID如何获取呢? 打开WifiManager.java源码,可找到 getWifiApState() 方法,惊喜的发现直接调用这个方法就能获取到热点的状态,然而在调 ...

  8. 驱动10.nor flash

    1 比较nor/nand flash NOR                                  NAND接口:    RAM-Like,引脚多                 引脚少, ...

  9. 间隔Ns请求某函数并且有timeout

    实现方案: 1. 递归调用 2.timer:apply_interval() 3.gen_server来写 时间timeout怎么实现: 1.开始时间存入ets表中 2.put,get方法放入进程字典 ...

  10. phpstorm9整合本地apache和豆沙绿主题设置(附资源)

    ♣phpstorm9下载(安装包和注册码) ♣phpstorm9自带apache和自定义apache服务器 ♣phpstorm9豆沙绿主题设置(附我的主题包) 说明:如果还未安装apache和php7 ...