- 博客(26)
- 资源 (1)
- 收藏
- 关注
转载 self的规则
self的规则大家需要记住下面的规则:1,实例方法里面的self,是对象的首地址。2,类方法里面的self,是Class.尽管在同一个类里面的使用self,但是self却有着不同的解读。在类方法里面的self,可以翻译成class self;在实例方法里面的self,应该被翻译成为object self。在类方法里面的self和实例方法里面的self有着本质上的不同,尽管他们的名字
2015-01-09 11:41:48
336
转载 UIView常用的一些方法小记之setNeedsDisplay和setNeedsLayout
1,UIView的setNeedsDisplay和setNeedsLayout方法 首先两个方法都是异步执行的。而setNeedsDisplay会调用自动调用drawRect方法,这样可以拿到 UIGraphicsGetCurrentContext,就可以画画了。而setNeedsLayout会默认调用layoutSubViews, 就可以 处理子视图中的一些数据。综
2014-12-24 15:13:59
334
转载 one sample about recursive function
---------------------------the code start--------------------------------------------------------#include void singSongFor(int numberOfBottles){ if (numberOfBottles == 0) { printf("
2014-12-22 17:25:44
323
转载 I have a custom view that I want to be able to initialize both in-code and in nib.
Objective C - Custom view and implementing init method?http://stackoverflow.com/questions/7226239/objective-c-custom-view-and-implementing-init-methodup vote16down
2014-12-04 11:16:56
566
转载 iOS 数据持久化
user defaults:NSUserDefaults*userDefaults = [NSUserDefaultsstandardUserDefaults]; [userDefaultssetBool:YESforKey:@"Key1"];[userDefaultssetInteger:123forKey:@"Ke
2014-12-02 10:07:20
312
转载 ios - firstObject vs objectAtIndex:0
There is one key difference. Using firstObject returns nil if there is none. Using objectAtIndex:0 will crash your app(throws an exception) if there is no object there.From a user experience persp
2014-12-02 09:35:13
400
转载 NSNotificationDemo
//// ViewController.m// NSNotification//// Created by Liming Tian on 11/25/14.// Copyright (c) 2014 Liming Tian. All rights reserved.//#import "ViewController.h"
2014-11-26 13:42:57
370
转载 数组排序
#include int main(void){ int i,j,p,q,s,a[10]; printf("\n input 10 numbers:\n"); for(i=0;i10;i++) { scanf("%d",&a[i]); } for (i = 0; i10; i++) {
2014-11-26 13:42:14
283
转载 loadView VS viewDidLoad
loadView is the method in UIViewController that will actually load up the view and assign it to the "view" property. This is also the location that a subclass of UIViewController would override if you
2014-10-22 16:01:49
358
转载 iOS7中UILabel高度调整注意事项
CGSize constraint = CGSizeMake(230, 1000); UILabel *lbl = [[UILabel alloc]init]; UIFont *font =[UIFont fontWithName:lbl.font.familyName size:16]; NSDictionary *dic = [NSDictionary dicti
2014-10-22 14:32:14
282
转载 shortcut of moving line
Xcode 4 has a new set of command for moving the line where the cursor is or the selected text withcommand + option + [ or ]
2014-10-20 09:34:12
268
转载 UIImageView userInteractionEnabled
为UIImageView的子空间添加事件时,必须打开其userInteractionEnabled
2014-10-17 11:09:58
414
转载 removeFromSuperview and addSubview relation with reference count?
Yes, if you create a view like this:UIView *myView = [[UIView alloc] init];The retain count is 1 and you are the owner.If you add this view to another view, the second view will be the own
2014-10-15 15:33:51
311
转载 巧妙利用nextResponder
通过UIViewController的view属性可以访问到其管理的view对象,及此view的所有subviews。但是根据一个view对象,没有直接的方法可以得到管理它的viewController,但我们使用responder chain可以间接的得到,代码如下:@implementation UIView (ParentController)-(UIViewController*
2014-10-14 16:01:48
864
转载 iOS默认的set方法
今天发现工程里有同事代码如下:-(void)dealloc{ [self.indicatorView release]; self.indicatorView = nil; [super dealloc];}这种低级错误必定导致崩溃。其实iOS本身一个property对象,如果是retain属性,调用它的赋值,其实是调用了如下代码:-(void
2014-10-14 11:04:29
374
转载 区别scrollViewDidEndDragging和scrollViewDidEndDecelerating
- (void)setContentOffset{ float index = floor((_contentScrollView.contentOffset.x - 35) / 70 + 1); NSLog(@"index : %.2f", index); [_contentScrollView setContentOffset:CGPointMak
2014-10-09 17:08:14
675
转载 layoutSubviews的调用时机
layoutSubviews在以下情况下会被调用: 1、init初始化不会触发layoutSubviews 2、addSubview会触发layoutSubviews 3、设置view的Frame会触发layoutSubviews,当然前提是frame的值设置前后发生了变化 4、滚动一个UIScrollView会触发layoutSubviews
2014-10-08 10:43:46
357
转载 Purpose of Instance Methods vs. Class Methods in Objective-C
Generally speaking, you should create instance methods when you need code that operates on a specific instance of an object. You create a class method when you need to do something that involves that
2014-10-06 17:05:52
348
转载 viewDidLoad VS viewWillAppear
viewDidLoad is things you have to do once. viewWillAppear gets called every time the view appears. You should do things that you only have to do once in viewDidLoad - like setting your UILabel texts
2014-09-27 18:21:34
279
转载 how to add pch to Xcode 6
Add new PCH file to the project - New file > Other > PCH fileAt the project 'Build Settings' option - set the value of 'Prefix Header' to your PCH file name, with the project name as prefix - i.e.
2014-09-22 16:53:03
308
转载 self.view.window在逻辑判断中的作用
iOS程序里面,window是程序视图层次体系的最高层。所有能看到的view,都是要加到这个window上才能被看到。不管是直接被加到window上,还是通过superview被间接的加到window上,总之一个view你要想看到它,它必须要被加到一个window上去。所以如果一个view的window属性为nil的话,就说明这个view没有被加到任何window上,是无法看到的。
2014-09-22 14:34:41
1560
转载 frame和bounds的区别,boundsVS applicationframe
frame和bounds是UIView中的两个属性(property)。frame指的是:该view在父view坐标系统中的位置和大小。(参照点是父亲的坐标系统)bounds指的是:该view在本身坐标系统中 的位置和大小。(参照点是本身坐标系统)-(CGRect)frame{ return CGRectMake(self.frame.origin.x,self.fra
2014-09-22 10:51:44
308
转载 类方法中self的用法
If you are calling another class method from inside a class method (of the same class) you can just use [self classMethod]. If however you are in an instance method and you need to call that classes
2014-08-20 15:34:54
656
转载 iOS应用崩溃日志揭秘
这篇文章还可以在这里找到 英语Learn how to make sense of crash logs!本文作者是 Soheil Moayedi Azarpour, 他是一名独立iOS开发者。作为一名应用开发者,你是否有过如下经历?为确保你的应用正确无误,在将其提交到应用商店之前,你必定进行了大量的测试工作。它在你的设备上也运行得很好,但是,上了应
2014-08-13 16:47:37
496
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人