iPhone/iOS
勇敢的小鸟
对不好的自己深深忏悔,对好的自己发挥到极致
展开
-
NSNotification+extern
// Child.hNSString *notificationName;#import @interface Child : NSObject{ NSInteger _sleepTime;}@property (nonatomic) NSInteger sleepTime;@end// Child.m#import "Child.h"@implemen原创 2013-07-12 15:03:18 · 543 阅读 · 0 评论 -
UILable sizeToFit
UILable的sizeToFit方法很不错,可以直接通过调用它改变label的frame- (void)viewDidLoad{ [super viewDidLoad]; // 对于多行文字的label,必湏指定宽度 // UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0,原创 2013-07-18 11:27:44 · 1500 阅读 · 0 评论 -
cancelPreviousPerformRequestsWithTarget
from stackoverflow: http://stackoverflow.com/questions/7589644/why-doesnt-cancelpreviousrequestswithtarget-cancel-an-nstimer#import "ViewController.h"@interface ViewController ()@end@implement原创 2013-07-29 13:58:41 · 1081 阅读 · 0 评论 -
[[UIScreen mainScreen] applicationFrame]
Just explain it with code:// ViewController.m#import "ViewController.h"#define kMainScreenFrame [[UIScreen mainScreen] bounds]#define kMainScreenWidth kMainScreenFrame.size.width#define kMainSc原创 2013-08-05 08:22:45 · 1029 阅读 · 0 评论 -
MD5 Hash NSURL
// ViewController.m#import "ViewController.h"#import // use MD5 Hash URL @implementation ViewController- (void)viewDidLoad{ [super viewDidLoad]; NSURL *url = [NSURL URLWithString:@"原创 2013-08-05 17:10:04 · 957 阅读 · 0 评论 -
NSDate
NSDate 比较:NSDate *date = [NSDate date];NSDate *laterDate = [date dateByAddingTimeInterval:1000];if ([date compare:laterDate] == NSOrderedAscending) { NSLog(@"NSOrderedAscending"); // output}原创 2013-08-05 09:47:11 · 906 阅读 · 0 评论 -
沙盒目录下创建文件夹
查看沙盒方法:前往 --> (按住option键) 资源库 --> Application Support --> iPhone Simulator --> ...在沙盒目录下创建文夹,可以用 - (BOOL)createDirectoryAtPath:(NSString *)path withIntermediateDirectories:(BOOL)createIntermedi原创 2013-08-06 16:02:29 · 1166 阅读 · 0 评论 -
UITableView代理方法的执行流程
just explain it with code:// ViewController.m#import "ViewController.h"@implementation ViewController- (void)viewDidLoad{ [super viewDidLoad]; _items = [[NSMutableArray alloc] in原创 2013-08-06 08:38:46 · 2171 阅读 · 0 评论 -
removeObjectIdenticalTo
removeObjectIdenticalTo函数会移除数组中所有地址相同的元素//// main.m#import int main(int argc, const char * argv[]){ @autoreleasepool { NSNumber *num_1 = @1; NSNumber *num_2 = @2;原创 2013-08-06 15:25:42 · 1335 阅读 · 0 评论 -
NSOperation/NSOperationQueue small demo
// ImageLoadOperation.h#import @interface ImageLoadOperation : NSOperation{ NSURL *_imageURL; id _target; SEL _action;}- (id)initWithImageURL:(NSURL *)imageURL target:(id)target ac原创 2013-08-06 16:19:08 · 1121 阅读 · 0 评论 -
宏
#import #define TARGET_MY_TEST_2 6000int main(int argc, const char * argv[]){ @autoreleasepool { #if TARGET_MY_TEST_1 NSLog(@"1"); // no output #if TARGET_MY_TEST_2原创 2013-08-08 15:09:25 · 857 阅读 · 0 评论 -
iOS文件管理 NSFileManager NSFileHandle
http://liuxing8807.blog.163.com/blog/static/9703530520133413353291/http://www.cnblogs.com/jay-dong/archive/2013/01/21/2870414.html原创 2013-08-08 09:11:44 · 1186 阅读 · 0 评论 -
dispatch_once
dispatch_once的意思是程序在执行期间只执行一次dispatch_once包含的代码:建一单视图应用程序:‘// TestClass.h#import @interface TestClass : NSObject- (void)test;@end// TestClass.m#import "TestClass.h"@implementation Te原创 2013-08-03 15:35:48 · 771 阅读 · 0 评论 -
NSNull nil Nil
//// ViewController.m// NULL nil Test Demo//// Created by WeiZhen_Liu on 13-7-29.// // http://nshipster.com/nil////** NSNull is used throughout Foundation and other frameworks to skirt ar原创 2013-08-03 10:14:13 · 735 阅读 · 0 评论 -
UITabBarItem文字的设置
设置位置:[tab.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -10)]设置高亮时文字颜色:NSDictionary *highlightedAttributes = [NSDictionary dictionaryWithObject:[UIColor orangeColor] forKey:UITextAttribu原创 2013-07-15 17:23:45 · 2691 阅读 · 0 评论 -
UILabel 显示null
- (void)viewDidLoad{ [super viewDidLoad]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 280, 40)]; // label.text = [NSString stringWithFormat:@"%@, %@", @"Hi", nil];原创 2013-07-16 09:09:42 · 1573 阅读 · 0 评论 -
私有属性
如果类的属性不直接通过点语法赋值可以写成私有的- (IBAction)testPropertyButtonClick:(id)sender { TestObject *testObj = [[TestObject alloc] init]; testObj.name = @"name"; NSLog(@"testObj.name: %@", testObj.name);原创 2013-07-17 10:49:52 · 540 阅读 · 0 评论 -
Some good hyperlink for learn iOS
OC自我翻译原创 2013-07-17 17:44:34 · 808 阅读 · 0 评论 -
画倒三角
- (void)viewDidLoad{ [super viewDidLoad]; CustomView *customView = [[CustomView alloc] initWithFrame:CGRectMake(20, 20, 280, 200)]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectM原创 2013-07-18 08:55:02 · 1034 阅读 · 0 评论 -
UIButton setShowsTouchWhenHighlighted
- (void)viewDidLoad{ [super viewDidLoad]; UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button setFrame:CGRectMake(20, 20, 280, 30)]; [button setTitle:@"TestS原创 2013-07-18 11:03:54 · 1107 阅读 · 0 评论 -
解决键盘遮挡UITextField问题
//// ViewController.m// UITextFieldScrollDemo//// Created by WeiZhen_Liu on 13-7-19.// Copyright (c) 2013年 WeiZhen_Liu. All rights reserved.//#import "ViewController.h"@interface ViewCon原创 2013-07-19 23:30:35 · 650 阅读 · 0 评论 -
NSLog中文问题
// main.m// Created by WeiZhen_Liu on 13-7-22.#import int main(int argc, const char * argv[]){ @autoreleasepool { char *pStr_1 = "hello world!"; char *pStr_2 = "hello 世界!";原创 2013-07-22 14:04:16 · 738 阅读 · 0 评论 -
UITextField/UITextView 选中时改变边框颜色
#import "ViewController.h"// first import QuartCore.framework and then add this line#import @interface ViewController () @end@implementation ViewController- (void)viewDidLoad{ [supe原创 2013-07-24 15:58:55 · 2583 阅读 · 0 评论 -
self and super
Just explain it with Code:// A.h#import @interface A : NSObject- (void)test;@end// A.m#import "A.h"@implementation A- (void)test{ NSLog(@"A test"); [self go];}- (void)go{原创 2013-08-03 10:21:38 · 749 阅读 · 0 评论 -
id
//// main.m// Created by WeiZhen_Liu on 13-8-1.//#import int main(int argc, const char * argv[]){ @autoreleasepool { id i = (id)90; printf("%d", (int)i);原创 2013-08-03 14:05:58 · 551 阅读 · 0 评论