Category Archives: 项目实战(iOS)

kCLErrorDomain Code=0终极解决方案!

1、在使用百度地图时,定位失败一般会报两种错:
Error Domain=kCLErrorDomain Code=0 “The operation couldn’t be completed. (kCLErrorDomain error 0.)”
Error Domain=
kCLErrorDomain Code=1 “The operation couldn’t be completed. (kCLErrorDomain error 1.)”
即我们所说的Code=0和Code=1,网上有很多帖子都说这是模拟器没有GPS硬件造成的xxxxxx,然而我们是真机呀,真机!!!

2、一提到是真机就没人BB了,就连百度地图开发者论坛都没人能正面回答这个问题,有些人可能模拟器的问题还没解决,那就先说模拟器吧!

3、关于模拟器我总结一下,比较中肯的说法是,Code=0说明没有位置信息,即没获取到GPS信息,因为没人提供GPS数据给模拟器,两种方式解决:
3.1、上两个图就明白了,说多人也是废话[……]

继续阅读

UISearchBar与UISearchDisplayController

1、一开始呢我是搞不清楚这两个东西有什么关系,或者说UISearchDisplayController我根本就没用过,那么就先来看下UISearchBar的使用效果

2、UISearchBar是个搜索工具条,这个控件的工作原理非常简单,他与UITextField其实有点像,能够监听开始搜索,搜索词变化,搜索结束等一系列状态,并调用代理的相关方法,这些功能UITextField不是也都有吗?只是他是专业的搜索控件,长得好看一点而已!

3、来,看下UISearchBar在TableView中的表现吧,两张图给你看出效果:[……]

继续阅读

关于UIView的alpha属性的探讨

1、UIView的alpha属性指的是视图的透明度,该属性值取值0~1,如果为0则说明视图为全透明,如果为1则完全不透明,我们通过示例来说明问题,先看原效果图

iOS Simulator Screen Shot 2015年5月22日 下午10.45.32

该窗口上一共有4个View,最底层为风景图,风景图上面为一个红色的View,红色View上面有两个子View,分别为蓝色View和绿色View,由于红色完全压在风景图上面,所以看不到风景图。
层级关系为
—UIImageView
—–UIView(redView)
——-UIView(greenView)
——-UIView(blueView)

2、问题来了,redView上面还有子视图blueView和greenView,那么设置该redView的alpha属性,子视图会怎样?我们来设置一下,代码:[……]

继续阅读

iOS制作自定义数字键盘

一、应用场景

很多情况下我们的输入都是有硬性要求的,比如只能输入数字,通常情况下我们的解决方案就是指定输入框的键盘模式(keyboardType),可系统提供给我的键盘种类还是非常有限的,如下所示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
typedef NS_ENUM(NSInteger, UIKeyboardType) {
????UIKeyboardTypeDefault,??????????????? // Default type for the current input method.
????UIKeyboardTypeASCIICapable,?????????? // Displays a keyboard which can enter ASCII characters, non-ASCII keyboards remain active
????UIKeyboardTypeNumbersAndPunctuation,? // Numbers and assorted punctuation.
????UIKeyboardTypeURL,??????????????????? // A type optimized for URL entry (shows . / .com prominently).
????UIKeyboardTypeNumberPad,????????????? // A number pad (0-9). Suitable for PIN entry.
????UIKeyboardTypePhonePad,?????????????? // A phone pad (1-9, *, 0, #, with letters under the numbers).
????UIKeyboardTypeNamePhonePad,?????????? // A type optimized for entering a person's name or phone number.
????UIKeyboardTypeEmailAddress,?????????? // A type optimized for multiple email address entry (shows space @ . prominently).
????UIKeyboardTypeDecimalPad NS_ENUM_AVAILABLE_IOS(4_1),?? // A number pad with a decimal point.
????UIKeyboardTypeTwitter NS_ENUM_AVAILABLE_IOS(5_0),????? // A type optimized for twitter text entry (easy access to @ #)
????UIKeyboardTypeWebSearch NS_ENUM_AVAILABLE_IOS(7_0),??? // A default keyboard type with URL-oriented addition (shows space . prominently).
?
????UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable, // Deprecated
?
};

[……]

继续阅读