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);