一. 前言

平时在处理问题的时候,经常会遇到一些奇奇怪怪的问题,今天在这里将其记录下来。这里将会列举几个常用的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. TCP/IP capture/analysis tools in Unix/Linux

    There are some useful tools in Unix/Linux to check out how the system is going on. Here is a short s ...

  2. PHP 数组拼接成字符串

    PHP[知识分享] 数组拼接成字符串 <?php // 格式: [二维数组] Array ( [0] => Array ( [topicid] => 1 ) [1] => Ar ...

  3. on IRC, how to use secure connection(SSL) and get a cloak/vhost to hide your IP

    On stackoverflow I found this: Follow this tutorial below: This is from http://superuser.com/questio ...

  4. 使用Cobertura统计JUnit测试覆盖率

    这是一个JavaProject,关于Cobertura的用法详见代码注释 首先是应用代码(即被测试的代码) package com.jadyer.service; public class Calcu ...

  5. 线程androidAndroid ConditionVariable的用法

    查了好多资料,发现还是不全,干脆自己整理吧,至少保证在我的做法正确的,以免误导读者,也是给自己做个记录吧! 在Android开辟中,如果需要线程同步,可以使用Java系统库的wait()和notify ...

  6. 使用pentaho工具将数据库数据导入导出为Excel

    写在前面:本篇博客讲述的是如何使用pentaho工具快速的将数据库数据导出为Excel文件,以及如何将Excel文件数据导入数据库. 补充:使用此工具并不需要任何一句代码并能快速便捷解决实际问题,此工 ...

  7. 简单的遮罩层效果,user登陆显示效果

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  8. 结构-行为-样式-Angularjs-ngSanitize

    简单点,上代码: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> < ...

  9. 错误: 找不到或无法加载主类 tomcat-juli.jar

    错误: 找不到或无法加载主类 tomcat-juli.jar 然后就可以用了.

  10. jQuery 效果 - fadeTo() 方法

    实例 使用淡出效果来隐藏一个 <p> 元素: $(".btn1").click(function(){ $("p").fadeTo(1000,0.4 ...