您的位置:首页 > 移动开发 > Objective-C

iOS开发--1【Objective-C】

2016-02-09 19:18 525 查看
1、IBAction vs. IBOutlet

用于storyboard或xib的连接。
Not used by the compiler, they are used by Interface Builder. -- use these keywords to parse out the outlets or actions.

Interface Builder: can only see methods that are prefaced with IBAction and see variables and properties that are prefaced with IBOutlet.

these variables and methods aren't deal with entirely in code, we need to delve into the relevant nib file to see how things are hooked up and used.

(weak, nonatomic)


2、View Controller

- job: to manage a single screen from your app. each
screen in your app gets its own view
controller.

- .h: tells the computer what the view controller does
- .m: tells the computer how it does those things


3、iOS9中关于alert的改变



4、Portrait vs. Landscape

- Device Orientation: if only landscape, go to Generate to uncheck portrait.

iPhone4:320*480
iPhone5:320*568
iPhone6:375*667


5、Slider

修改slider默认样式:



slider.value【UISlider】

- (IBAction)sliderMoved:(UISlider *)slider{
NSLog(@"%f", slider.value);
}

slider的值是float形式


6、取整【%d】

int(): 取小数点前的整数
round(): 四舍五入取最近的整数


7、Local variables vs. instance variables

local variables: exist very breifly
eg: message
instance variables: lives on forever, 前面有下划线
eg: _message


8、Properties vs. instance variables

properties: "backed" by an instance variable
preperty-->store its value somewhere<--an instance variable is a good place for that

properties are always accessed using [self]:

- this uses the property:
self.slider.value = 50;
【property can be accessed by other objects that are outside of your view controller.】

- this uses the backing instance variable directly:
_slider.value = 50;
【are supposed to be used only by the insides of an object, other objects aren't intended to see them or use them.】


9、Generate the random number

arc4random_uniform(N):生成N-1的随机数
一般:arc4random_uniform(N) + 1: 生成1-100随机数


10、iOS9 Storyboard Segue

- show: 把新的内容push到当前view controller stack顶部
- show detail: 把新的内容取代view controller stack顶部
- present modally: 模态展示内容
- present as popover: 在当前的view上出现一个小窗口来展示内容(如:选中文字出现 复制/翻译 的按钮)


返回上一页:



11、webView,加载htmlFile



12、CATransition【Core Animation】



13、自动布局

屏幕适配:pin–>constraints

永远居中: Align

多元素自动布局: 选中一部分elements–>Editor–>View

之后把view的background color变为clear
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios ios开发