不知是哪个号

It's never too old to learn.


  • Home

  • About

  • Tags

  • Categories

iOS7以后UITextView的那些坑

Posted on 2015-10-13 | In iOS | Visitors:
Words count in article: 241 words | Reading time ≈ 1 minutes

坑1:

iOS7及以上的版本上,UITextView出现这样的问题:弹出键盘时,没输入任何文字,但是光标位置不是在最上方

1
2
3
4
5
6
解决方案: 
iOS7以后新增了一个属性automaticallyAdjustsScrollViewInsets,将其置为NO即可。别忘了加版本判断。

if (IOS7_And_Later) {
self.automaticallyAdjustsScrollViewInsets = NO;
}

坑2:

iOS7及以上的版本上,UITextView输入中文时,在输入多行后,光标有时会上下跳动,输入文字的时候内容有时会往上跳,光标都显示不出来。这个bug坑死好多人啊,特别是做聊天输入框的时候,不得已找一些非正常的方法解决。从网上找的各种解决方案都不行。

解决方案:

1
2
3
4
5
6
7
8
9
10

- (void)textViewDidChangeSelection:(UITextView *)textView {
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
CGRect r = [textView caretRectForPosition:textView.selectedTextRange.end];
CGFloat caretY = MAX(r.origin.y - textView.frame.size.height + r.size.height + 8, 0);
if (textView.contentOffset.y < caretY && r.origin.y != INFINITY) {
textView.contentOffset = CGPointMake(0, caretY);
}
}
}

node 学习

Posted on 2015-08-20 | In Node | Visitors:
Words count in article: 789 words | Reading time ≈ 3 minutes

1. node 基础

(1)node定义:JS是脚本语言,脚本语言都需要一个解析器才能运行。对于写在HTML页面里的JS,浏览器充当了解析器的角色。而对于需要独立运行的JS,NodeJS就是一个解析器。

每一种解析器都是一个运行环境,不但允许JS定义各种数据结构,进行各种计算,还允许JS使用运行环境提供的内置对象和方法做一些事情。例如运行在浏览器中的JS的用途是操作DOM,浏览器就提供了document之类的内置对象。而运行在NodeJS中的JS的用途是操作磁盘文件或搭建HTTP服务器,NodeJS就相应提供了fs、http等内置对象

Read more »

iOS tips

Posted on 2015-05-13 | In iOS | Visitors:
Words count in article: 187 words | Reading time ≈ 1 minutes

文件 ARC && MRC 设置

ARC 项目中使用 MRC 文件 使用

1
-fno-objc-arc

MRC 项目中使用 ARC 文件 使用

1
-fobjc-arc

具体设置如下所示:

Read more »

iOS时间转换

Posted on 2015-04-11 | In iOS | Visitors:
Words count in article: 1.2k words | Reading time ≈ 4 minutes

原文地址

字符说明

(:)

时间分隔符。在某些区域设置中,可以使用其他字符表示时间分隔符。时间分隔符在格式化时间值时分隔小时、分钟和秒。格式化输出中用作时间分隔符的实际字符由您的应用程序的当前区域性值确定。

(/)

日期分隔符。在某些区域设置中,可以使用其他字符表示日期分隔符。日期分隔符在格式化日期值时分隔日、月和年。格式化输出中用作日期分隔符的实际字符由您的应用程序的当前区域性确定。

Read more »

git常用命令

Posted on 2015-01-25 | In Tool | Visitors:
Words count in article: 620 words | Reading time ≈ 2 minutes

原文地址

git常用命令

1
2
3
4
5
6
7
8
# 添加一个文件(到暂存区stage)
git add <name>

# 查看文件修改或添加
git status

# 记录一次修改
git commit -a "description"

提交文件修改等操时,强烈建议按照上述顺序执行。

Read more »

xml解析

Posted on 2014-10-23 | In iOS | Visitors:
Words count in article: 700 words | Reading time ≈ 3 minutes

在IOS平台上进行XML文档的解析有很多种方法,在SDK里面有自带的解析方法,但是大多情况下都倾向于用第三方的库,原因是解析效率更高、使用上更方便,关于IOS平台各种解析XML库的优缺点分析,可以看下这篇文章:

http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project

这里主要介绍一下由Google提供的一种在IOS平台上进行XML解析的开源库GDataXML,可以到

http://code.google.com/p/gdata-objectivec-client/source/browse/trunk/Source/XMLSupport/

下载源码,下载下来后进入文件夹找到XMLSupport文件夹,将里面的GDataXMLNode.h和GDataXMLNode.m文件拖拽到项目中新建的文件夹即可(我这里是建的GDataXML文件夹),注意要选中复制文件到项目中而不是只是引用,如图:

Read more »

编译问题

Posted on 2014-08-21 | In iOS | Visitors:
Words count in article: 135 words | Reading time ≈ 1 minutes

编译正常,但无法运行到真机和模拟器上

Choose a destination with a supported architecture

avatar

这样的错误解决办法

Read more »

AppB中获取AppA的照片

Posted on 2014-06-20 | In iOS | Visitors:
Words count in article: 172 words | Reading time ≈ 1 minutes

URLType配置

分别配置 两个应用的 URLType

AppA定义URLType为AppA0000000000

AppB定义URLType为AppB0000000000

Read more »

静态库制作及注意事项

Posted on 2014-05-13 | In iOS | Visitors:
Words count in article: 859 words | Reading time ≈ 3 minutes

方法一

参考文章连接: xcode 4 制作静态库详解

方法二

在原有工程上操作,打开已存在的工程,然后添加一个要做成.a静态库的 Target 在此,简单命名为mylibrary

Read more »

导航栏和状态栏

Posted on 2014-04-18 | In iOS | Visitors:
Words count in article: 372 words | Reading time ≈ 1 minutes

状态栏

1
2
3
4
5
6
7
8
9
10
11
12
13
    
typedef NS_ENUM(NSInteger, UIStatusBarStyle) {
UIStatusBarStyleDefault = 0, // 白底黑子
UIStatusBarStyleLightContent NS_ENUM_AVAILABLE_IOS(7_0) = 1, // 黑底白字
UIStatusBarStyleBlackTranslucent NS_ENUM_DEPRECATED_IOS(2_0, 7_0, "Use UIStatusBarStyleLightContent") = 1,
UIStatusBarStyleBlackOpaque NS_ENUM_DEPRECATED_IOS(2_0, 7_0, "Use UIStatusBarStyleLightContent") = 2,
} __TVOS_PROHIBITED;


//默认的值是黑色的
-(UIStatusBarStyle)preferredStatusBarStyle NS_AVAILABLE_IOS(7_0) {
return UIStatusBarStyleDefault;
}
Read more »
1…34

40 posts
6 categories
9 tags
© 2020
Powered by Hexo
|
Theme — NexT.Pisces v5.1.4