This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
继承并实现 | |
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event | |
{ | |
[[self nextResponder] touchesBegan:touches withEvent:event]; | |
} | |
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event | |
{ | |
UITouch * touch = [touches anyObject]; | |
CGPoint touchPoint = [touch locationInView:self]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. iOS版本确认 | |
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 4.0) { | |
bannerView = [[ADBannerView alloc] init]; | |
bannerView.delegate = self; | |
[self.view addSubview:bannerView]; | |
} | |
2. 新类是否存在 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//崩溃后程序保持运行状态而不退出 | |
CFRunLoopRef runLoop = CFRunLoopGetCurrent(); | |
CFArrayRef allModes = CFRunLoopCopyAllModes(runLoop); | |
while (!dismissed) | |
{ | |
for (NSString *mode in (__bridge NSArray *)allModes) | |
{ | |
CFRunLoopRunInMode((__bridge CFStringRef)mode, 0.001, false); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSDate *date = [NSDate date]; | |
// 调整8小时时差 | |
NSTimeZone *zone = [NSTimeZone systemTimeZone]; | |
NSInteger interval = [zone secondsFromGMTForDate:date]; | |
NSDate *localeDate = [date dateByAddingTimeInterval: interval]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//绘制三角 | |
- (void)drawRect:(CGRect)rect | |
{ | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextBeginPath(context); | |
CGContextMoveToPoint (context, CGRectGetMinX(rect), CGRectGetMaxY(rect)); | |
CGContextAddLineToPoint(context, CGRectGetMidX(rect), CGRectGetMinY(rect)); | |
CGContextAddLineToPoint(context, CGRectGetMaxX(rect), CGRectGetMaxY(rect)); | |
CGContextClosePath(context); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1、 三角函数 | |
double sin (double);正弦 | |
double cos (double);余弦 | |
double tan (double);正切 | |
2 、反三角函数 | |
double asin (double); 结果介于[-PI/2, PI/2] | |
double acos (double); 结果介于[0, PI] | |
double atan (double); 反正切(主值), 结果介于[-PI/2, PI/2] | |
double atan2 (double, double); 反正切(整圆值), 结果介于[-PI, PI] | |
3 、双曲三角函数 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AFHTTPRequestOperation * operation = [_AFManager POST:[_baseURL stringByAppendingString:MCSetavatarInterface] parameters:dic constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { | |
[formData appendPartWithFileURL:[dic objectForKey:@"url"] name:@"avatar" error:nil]; | |
} success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (AppDelegate *)sharedAppDelegate { | |
return (AppDelegate *)[[UIApplication sharedApplication] delegate]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Returns the path to the application's documents directory. | |
*/ | |
- (NSString *)applicationDocumentsDirectory { | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; | |
return basePath; | |
} |
NewerOlder