1.本地通知,应用按HOME退出到后台,10秒后本地发起通知。(相似于push通知)lua
UILocalNotification *notification=[[UILocalNotification alloc] init]; spa
if (notification!=nil) { orm
NSLog(@">> support local notification"); it
NSDate *now=[NSDate new]; io
notification.fireDate=[now addTimeInterval:10]; email
notification.timeZone=[NSTimeZone defaultTimeZone]; import
notification.alertBody=@"该去吃晚饭了!"; 后台
[[UIApplication sharedApplication].scheduleLocalNotification:notification];date
}im
2.判断邮箱输入是否正确。
- (BOOL) validateEmail: (NSString *) candidate {
NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}";
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
return [emailTest evaluateWithObject:candidate];
}
3.如何保存当前视图到相册。
#import <QuartzCore/QuartzCore.h>
UIGraphicsBeginImageContext(currentView.bounds.size); //currentView 当前的view
[currentView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);