NSIndexPath * indexPat=[NSIndexPath indexPathForRow:indexPlay inSection:0];
NSArray * indexArray=[NSArray arrayWithObject:indexPat]; [self.tableView reloadRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationAutomatic];
2. 判斷該方法是否執行??html
BOOL isss= [cell.queuePlayer respondsToSelector:@selector(play)];ios
int (^oneFrom)(int) = ^(int anInt) { return anInt -1; }; NSLog(@"%d",oneFrom(10));
4. 改變buuton的高亮git
UIImageView * iv = [[UIImageView alloc] initWithFrame:CGRectMake(250, 5, 50, 34)]; iv.userInteractionEnabled = YES; UIButton * navBtn = [UIButton buttonWithType:UIButtonTypeCustom]; navBtn.frame = CGRectMake(0, 0, 50, 34); [navBtn setImage:[UIImage imageNamed:@"rong_Tian"] forState:UIControlStateNormal]; [navBtn setHighlighted:YES]; [navBtn addTarget:self action:@selector(btnPressed:) forControlEvents:UIControlEventTouchUpInside]; [navBtn setShowsTouchWhenHighlighted:YES]; [iv addSubview:navBtn]; [self.navigationController.navigationBar addSubview:iv];
5. 默認爲cell第一行web
NSIndexPath *first=[NSIndexPath indexPathForRow:0 inSection:0];數組
[self.tableView selectRowAtIndexPath:first animated:YES scrollPosition:UITableViewScrollPositionBottom];瀏覽器
6.一個項目中 ARC和非ARC 的混合使用緩存
點擊項目--》TARGETS-》Build Phases -》Compile Sources 中選擇要改的.m 雙擊 在標籤中寫:cookie
1.若是是ARC項目,要加入非ARC的代碼文件 fobjc-arc多線程
2.若是是非ARC,要加入ARC的代碼 -fno-objc-arc Enter就OK 併發
//NSURL * url=[NSURL URLWithString:str]; //NSURLRequest *requestt = [[NSURLRequest alloc]initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10]; //NSData *received = [NSURLConnection sendSynchronousRequest:requestt returningResponse:nil error:nil]; //NSString *strr = [[NSString alloc]initWithData:received encoding:NSUTF8StringEncoding]; //NSLog(@"這是 成功返回的信息 %@",strr);
7.距離感應器
UIDeviceOrientation orientation3= [[UIDevice currentDevice] orientation]; NSLog(@"獲取當前狀態 %d",orientation3); [[UIDevice currentDevice] setProximityMonitoringEnabled:YES]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sensorStateChange:) name:@"UIDeviceProximityStateDidChangeNotification" object:nil]; - (void)sensorStateChange:(NSNotificationCenter *)notification { if ([[UIDevice currentDevice] proximityState] == YES) { NSLog(@"Device is close to user"); //在此寫接近時,要作的操做邏輯代碼 } else { NSLog(@"Device is not close to user"); } }
8.得到cookie
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage]; for (NSHTTPCookie *cookie in [cookieJar cookies]) { NSLog(@"cookie===== %@", cookie); }
9.從相冊中只得到視頻文件
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] == YES) { UIImagePickerController *videoLibraryController = [[[UIImagePickerController alloc] init] autorelease]; videoLibraryController.delegate = self; videoLibraryController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; videoLibraryController.mediaTypes = [NSArray arrayWithObject:(NSString *)kUTTypeMovie]; [videoLibraryController setAllowsEditing:YES];
[self.navigationController presentViewController:videoLibraryController animated:YES completion:^{ }]; } else { [self AlertlogError:@"暫時你尚未視頻"]; }
10. 讀取全局的Delegate:
KiloNetAppDelegate *appdelegate = (KiloNetAppDelegate *)[[UIApplication sharedApplication] delegate];
11.鍵盤透明
textField.keyboardAppearance = UIKeyboardAppearanceAlert;
Error Domain=ASIHTTPRequestErrorDomain Code=5 "Unable to create request (bad url?)" UserInfo=0x69ba0f0 {NSLocalizedDescription=Unable to create request (bad url?)}
解決辦法:
NSString*url =@"http://oerp.xixingsoft.com:8083/oadata/MobileConfig.nsf/GetStandList?openagent&ViewNumber=新聞中心";
url=[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSStringEncodingenc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);//gbk code-->utf8 code
NSData*data = [url dataUsingEncoding:NSUTF8StringEncoding];//[request responseData];
NSString*utf8str = [[[NSStringalloc] initWithData:data encoding:enc] autorelease];
13.請求中加cookie、 heard
當你須要添加更多的請求信息時,如,添加個請求Header:
[request addRequestHeader:@"name" value:@"Jory lee"];
14 Plist文件的保存 修改 除非在decument是可讀可寫的(在工程中 可讀不可寫)
//獲取路徑對象
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//獲取完整路徑
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *plistPath = [documentsDirectory stringByAppendingPathComponent:@"test.plist"];
NSLog(@"plist 地質 %@",plistPath);
NSMutableDictionary *dictplist = [[NSMutableDictionary alloc ] init];
[dictplist setObject:self.strWeb_id forKey:@"web_id"];
[dictplist writeToFile:plistPath atomically:YES];
15.獲取文件夾的大小
-(long long) fileSizeAtPath:(NSString*) filePath{
NSFileManager* manager = [NSFileManager defaultManager];
if ([manager fileExistsAtPath:filePath]){
return [[manager attributesOfItemAtPath:filePath error:nil] fileSize];
}
return 0;
}
16.改變tablevlewcell點擊的顏色
cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:cell.frame] autorelease];
cell.selectedBackgroundView.backgroundColor = [UIColor colorWithRed:54/255.0f green:110/255.0f blue:100/255.0f alpha:1.0f];
字
cell.textLabel.highlightedTextColor = [UIColor xxxcolor]; [cell.textLabel setTextColor:color
點擊後,過段時間cell自動取消選中
[self performSelector:@selector(deselect) withObject:nil afterDelay:0.5f];
- (void)deselect
{
[self.tableVieww deselectRowAtIndexPath:[self.tableVieww indexPathForSelectedRow] animated:YES];
}
17.改變UITableViewStyleGrouped背景顏色
self.tableVieww.backgroundColor =[UIColor colorWithPatternImage:[UIImage imageNamed:@"更多背景圖.png"]];
self.tableVieww.backgroundView =nil;
18.視圖反轉
//水平
queuePlayer.transform = CGAffineTransformScale(queuePlayer.transform, 1.0, -1.0);
//垂直 queuePlayer.transform = CGAffineTransformScale(queuePlayer.transform, -1.0, 1.0);
19.改變icon的陰影圓圈,取消圖標上的高光
1.進入plist文件 2.在Supported interface orientations 添加 Icon already includes
gloss effects 設置爲YES 也就是用本身的icon,不用系統的了
20.動態UIlable後添加圖片
self.userNameLabel=[[[UILabel alloc]initWithFrame:CGRectMake(60, 7, 220, 20)]autorelease];
self.userNameLabel.textColor= [UIColor blackColor];
self.userNameLabel.text=self.strNamee;
self.userNameLabel.backgroundColor=[UIColor clearColor];
self.userNameLabel.numberOfLines=0;
UIFont *font = [UIFont fontWithName:@"Helvetica-Bold" size:17.0f];
[self.userNameLabel setFont:font];
[self.contentView addSubview:self.userNameLabel];
CGSize size = [self.strNamee sizeWithFont:font constrainedToSize:CGSizeMake(277, 20.0f)];
NSLog(@"kuang %f ",size.width);
CGRect rect=self.userNameLabel.frame;
rect.size=size;
NSLog(@"321 %f %f",rect.size.width,rect.size.height);
[self.userNameLabel setFrame:rect];
//判斷男女
UIImageView * imaSex=[[UIImageView alloc]initWithFrame:CGRectMake(self.userNameLabel.frame.size.width+65, 10, 12, 13)];
21.向自定義的cell中傳值,最好用 方法在tableview中來調用 若是有參數 直接來傳//時間差
- (NSString *)intervalSinceNow: (NSString *) theDate
{
NSDateFormatter *date=[[NSDateFormatter alloc] init];
[date setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *d=[date dateFromString:theDate];
NSTimeInterval late=[d timeIntervalSince1970]*1;
NSDate* dat = [NSDate dateWithTimeIntervalSinceNow:0];
NSTimeInterval now=[dat timeIntervalSince1970]*1;
NSString *timeString=@"";
NSTimeInterval cha=now-late;
if (cha/3600<1) {
timeString = [NSString stringWithFormat:@"%f", cha/60];
timeString = [timeString substringToIndex:timeString.length-7];
timeString=[NSString stringWithFormat:@"%@分鐘前", timeString];
}
if (cha/3600>1&&cha/86400<1) {
timeString = [NSString stringWithFormat:@"%f", cha/3600];
timeString = [timeString substringToIndex:timeString.length-7];
timeString=[NSString stringWithFormat:@"%@小時前", timeString];
}
if (cha/86400>1)
{
timeString = [NSString stringWithFormat:@"%f", cha/86400];
timeString = [timeString substringToIndex:timeString.length-7];
timeString=[NSString stringWithFormat:@"%@天前", timeString];
}
[date release];
return timeString;
}
22.按鈕在cell上單擊第幾行
在cell.contentView上:
//得到row
NSInteger row = [[self.tableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]] row];
//得到section
NSInteger row = [[self.tableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]] section];
//得到indexPath
NSIndexPath *indexPath = [self.tableView indexPathForCell:(UITableViewCell *)[[sender superview] superview]];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(rongTianOrientation:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
- (void) deviceOrientationDidChangeAction:(NSNotification *)note
{
NSInteger currentOrientation = [[note object] orientation];
switch (currentOrientation) {
case0: { //未知方向
break;
}
case1: { //home鍵向下
break;
}
case2: { //home鍵向上
break;
}
case3: { //home鍵向左
break;
}
case4: { //home鍵向右
break;
}
default:
break;
}
}
24.模擬器不能運行的錯誤
dyld: Library not loaded: @rpath/SenTestingKit.framework/Versi*****/A/SenTestingKit
Referenced from: /Users/⋯⋯/Application Support/iPhone Simulator/5.0/Applicati*****/F179924C-0EB7-4CCA-88D6-3BA1F68F122D/ILUTU.app/ILUTU
Reason: image not found
把SentestingKit。 frameWork 有原來的required改成Optional 就ok
25.還原狀態欄
顯示原來的狀態欄
(1)
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:YES];
[[UIApplication sharedApplication].keyWindow setFrame:CGRectMake(0, 20, 320, [UIScreen mainScreen].applicationFrame.size.height)];
//從新設定標題欄顯示的位置
[self.navigationController.navigationBar setFrame:CGRectMake(0, 0, 320, 44)];
(2)
在別的頁面[[UIApplication sharedApplication].keyWindow setFrame:CGRectMake(0, 0, 320, [UIScreenmainScreen].applicationFrame.size.height)];
- (int)getVideopTime:(NSURL * )videourl
{
NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumbernumberWithBool:NO]
forKey:AVURLAssetPreferPreciseDurationAndTimingKey];
AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:videourl options:opts]; // 初始化視頻媒體文件
int minute = 0, second = 0;
second = urlAsset.duration.value / urlAsset.duration.timescale; // 獲取視頻總時長,單位秒
NSLog(@"movie duration : %d", second);
if (second >= 60) {
int index = second / 60;
minute = index;
second = second - index*60;
}
return second;
}
27.視頻播放器 循環播放 大小……
(1) MPMoviePlayerController
MPMoviePlayerController *player;
NSURL *url =[NSURL URLWithString:fileName];
player = [[MPMoviePlayerController alloc] init];
player.view.frame = CGRectMake(10, 30, 300 , 225);
player.contentURL = url;
player.repeatMode = MPMovieRepeatModeOne;
player.controlStyle = MPMovieControlStyleEmbedded;
player.scalingMode = MPMovieScalingModeAspectFill; //充滿屏幕
[self.view addSubview:player.view];
[player play];
(2).avplayer
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification
object:plaitem];
}
}];
#pragma mark - Notification Callbacks
- (void)playerItemDidReachEnd:(NSNotification *)notification {
NSLog(@"是跳轉第一偵嗎? ");
[self.queuePlayer seekToTime:kCMTimeZero];
[self.queuePlayer play];
}
28.sina微博錯誤返回值格式
http://open.weibo.com/wiki/Error_code
29.iOS 得到文件夾的大小
//計算文件夾下文件的總大小
-(long)fileSizeForDir:(NSString*)path
{
NSFileManager *fileManager = [[NSFileManager alloc] init];
long size = 0;
NSArray* array = [fileManager contentsOfDirectoryAtPath:path error:nil];
for(int i = 0; i<[array count]; i++)
{
NSString *fullPath = [path stringByAppendingPathComponent:[array objectAtIndex:i]];
BOOL isDir;
if ( !([fileManager fileExistsAtPath:fullPath isDirectory:&isDir] && isDir) )
{
NSDictionary *fileAttributeDic=[fileManager attributesOfItemAtPath:fullPath error:nil];
size+= fileAttributeDic.fileSize;
} else {
[self fileSizeForDir:fullPath];
}
}
[fileManager release]; return size; }
30. iOS 謂詞過濾 (ios 謂詞)
//搜索用謂詞過濾數組
NSArray * arrMy=@[@"張2榮三a",@"李四b",@"王五a",@"李流j",@"榮天321",@"iOS基地",@"iOS7"];
NSString * strg=@"榮";
NSPredicate * fiecate=[NSPredicate predicateWithFormat:@"SELF CONTAINS %@",strg];
NSArray * arr3=[arrMy filteredArrayUsingPredicate:fiecate];
NSLog(@"這是我過濾的數組對嗎?%@",arr3);
31.多線程的多種建立
// NSThread * th=[[NSThread alloc]initWithTarget:self selector:@selector(thAction) object:nil];
// [th start];
//[NSThread detachNewThreadSelector:@selector(thAction) toTarget:self withObject:nil];
// [self performSelectorInBackground:@selector(thAction) withObject:self];
// NSOperationQueue * operationQueue=[[NSOperationQueue alloc]init];
// [operationQueue addOperationWithBlock:^{
// for(int i=0; i<20;i++){
// NSLog(@"This isThread: %d",i);
// }
// }];
// NSOperationQueue * operationQueue=[[NSOperationQueue alloc]init];
// //設置線程池中的併發數
// operationQueue.maxConcurrentOperationCount=1;
//
// NSInvocationOperation * invocation1=[[NSInvocationOperation alloc]initWithTarget:self selector:@selector(threadOne) object:nil];
// [invocation1 setQueuePriority:NSOperationQueuePriorityLow];
//
// NSInvocationOperation * invocation2=[[NSInvocationOperation alloc]initWithTarget:self selector:@selector(threadTwo) object:nil];
// [invocation2 setQueuePriority:NSOperationQueuePriorityHigh];
// [operationQueue addOperation:invocation1];
// [operationQueue addOperation:invocation2];
32.用多線程開啓Nstimer提升精確度
//用多線程開啓nstimer提升精確度
- (void)mutiThread
{
NSLog(@"Start NStimer");
@autoreleasepool {
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerAction:) userInfo:nilrepeats:YES];
}
//得到當前的runloop,線程就停在這裏
[[NSRunLoop currentRunLoop]run];
NSLog(@"after");
}
- (void)timerAction:(NSTimer * )timer
{
i++;
NSLog(@"Print NSTimer");
if (i==5) {
[timer invalidate];
}
}
33.判斷此頁面是push,仍是模態過來的
if (self.presentingViewController) {
NSLog(@"這個是模態過來的!");}
34。等比例放大縮小視圖
UILabel * la=(UILabel * )[self.view viewWithTag:908];
[UIView animateWithDuration:.5 animations:^{
CGAffineTransform transform=la.transform;
transform=CGAffineTransformScale(la.transform, 1.5, 1.5);
la.transform=transform;
} completion:^(BOOL finished) {
CGAffineTransform transform=la.transform;
transform=CGAffineTransformScale(la.transform, 0.5, 0.5);
la.transform=transform;
}];
35.清掉編譯文件
~/Library/Developer/Xcode/DerivedData
模擬器清空編譯
~/Library/Application Support/iPhone Simulator/
36.改變狀態欄的顏色狀態
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
37.給本身的項目中添加特殊的標示符號
http://patorjk.com/software/taag/#p=moreopts&h=0&v=1&f=優雅&t=V
38 清空某個文件夾
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *outputURL = paths[0];
[NSFileManager.new removeItemAtPath:outputURL error:nil];
[NSFileManager.new createDirectoryAtPath:outputURL
withIntermediateDirectories:YES
attributes:nil
error:NULL];
39. 在document下建立文件
NSString *writePath=[NSString stringWithFormat:@"%@/%@.txt",stre,@"aaa"];
NSData *data = [@"" dataUsingEncoding:NSUTF8StringEncoding];//新文件的初始數據,設爲空
[[NSFileManager defaultManager] createFileAtPath:writePath contents:data attributes:nil];//建立文件的命令在這裏
40.layoutSubviews在如下狀況下會被調用:
一、init初始化不會觸發layoutSubviews
二、addSubview會觸發layoutSubviews
三、設置view的Frame會觸發layoutSubviews,固然前提是frame的值設置先後發生了變化
四、滾動一個UIScrollView會觸發layoutSubviews
五、旋轉Screen會觸發父UIView上的layoutSubviews事件
六、改變一個UIView大小的時候也會觸發父UIView上的layoutSubviews事件
41.蘋果審覈加急通道
https://developer.apple.com/appstore/contact/?topic=expedite
51 .美化配置Git log
$ git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)
52. Default.png 添加動畫
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
RootViewController *rooViewController = [[RootViewController alloc]init];
RTNavigationController *navgationVC = [[RTNavigationController alloc]initWithRootViewController:rooViewController];
self.window.rootViewController = navgationVC;
UIImageView *splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 568)];
splashView.image = [UIImage imageNamed:@"Default.png"];
[self.window addSubview:splashView];
[self.window bringSubviewToFront:splashView];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView: self.window cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
splashView.alpha = 0.0;
splashView.frame = CGRectMake(-60, -85, 440, 635);
[UIView commitAnimations];
[self.window makeKeyAndVisible];
return YES;
}
53.調用系統 電話, 特定的
一、調用 電話phone [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://4008008288"]];
二、調用自帶 瀏覽器 safari [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.zhece.com"]];
三、調用 自帶mail [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@abt.com"]];
四、調用 SMS [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://800888"]]; 5,跳轉到系統設置相關界面
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
其中,發短信,發Email的功能只能填寫要發送的地址或號碼,沒法初始化發送內容,若是想實現內容的話,還須要更復雜一些,實現其各自的委託方法。
若須要傳遞內容能夠作以下操做: 加入:MessageUI.framework #import 實現代理:MFMessageComposeViewControllerDelegate
- 調用sendSMS函數
- //內容,收件人列表
- - (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
- {
- MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
- if([MFMessageComposeViewController canSendText])
- {
- controller.body = bodyOfMessage;
- controller.recipients = recipients;
- controller.messageComposeDelegate = self;
- [self presentModalViewController:controller animated:YES];
- }
- }
- // 處理髮送完的響應結果
- - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
- {
- [self dismissModalViewControllerAnimated:YES];
- if (result == MessageComposeResultCancelled)
- NSLog(@"Message cancelled")
- elseif (result == MessageComposeResultSent)
- NSLog(@"Message sent")
- else
- NSLog(@"Message failed")
- }
- 發送郵件的爲:
- 導入#import
- 實現代理:MFMailComposeViewControllerDelegate
- //發送郵件
- -(void)sendMail:(NSString *)subject content:(NSString *)content{
- MFMailComposeViewController *controller = [[[MFMailComposeViewController alloc] init] autorelease];
- if([MFMailComposeViewController canSendMail])
- {
- [controller setSubject:subject];
- [controller setMessageBody:content isHTML:NO];
- controller.mailComposeDelegate = self;
- [self presentModalViewController:controller animated:YES];
- }
- }
- //郵件完成處理
- -(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
- [self dismissModalViewControllerAnimated:YES];
- if (result == MessageComposeResultCancelled)
- NSLog(@"Message cancelled");
- elseif (result == MessageComposeResultSent)
- NSLog(@"Message sent");
- else
- NSLog(@"Message failed");
- }
默認發送短信的界面爲英文的,解決辦法爲:在.xib 中的Localization添加一組chinese
54.程序中獲取軟件的版本號和app名稱
-
- 應用程序的名稱和版本號等信息都保存在mainBundle的infoDictionary字典中,用下面代碼能夠取出來。
- NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];
- NSString* versionNum =[infoDict objectForKey:@"CFBundleVersion"];//版本名稱
- NSString*appName =[infoDict objectForKey:@"CFBundleDisplayName"];//app名稱
- NSString*text =[NSString stringWithFormat:@"%@ %@",appName,versionNum];
好比,若是咱們作一個播放視頻的功能時,想在播放的時候,不會自動進入屏保(黑屏)
只要在代碼里加入這一行:
- [[UIApplication sharedApplication] setIdleTimerDisabled:YES];
固然,在想要黑屏的時候還須要把它設置爲NO(好比視頻播放完畢時),否則屏幕會在此軟件運行下一直亮着。
- 56。如何設置視圖(view)在最上層?或是view1和view2交換?
- self.view exchangeSubviewAtIndex:withSubviewAtIndex:];
NSArray *viewControllers = [self.navigationController viewControllers];
UIViewController *viewControll = [viewControllers objectAtIndex:2];
[self.navigationController pushViewController:viewControll animated:YES];
58,圖片模糊化處理
- +(UIImage *)scale:(UIImage *)image toSize:(CGSize)size
- {
- UIGraphicsBeginImageContext(size);
- [image drawInRect:CGRectMake(0, 0, size.width, size.height)];
- UIImage *scaledImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return scaledImage;
- }
dispatch_group_async(grounp, dispatch_get_global_queue(0, 0), ^{
NSLog(@" zhece.com >>>>>>>>>>> 1 ");
});
dispatch_group_async(grounp, dispatch_get_global_queue(0, 0), ^{
NSLog(@" zhece.com >>>>>>>>>>> 2 ");
});
dispatch_group_notify(grounp, dispatch_get_global_queue(0, 0), ^{
NSLog(@" zhece.com >>>>>>>>>>> 多線程完成,總執行 ");
});
beginBackgroundTaskWithExpirationHandler
方法,讓app最多有10分鐘的時間在後臺長久運行。這個時間能夠用來作清理本地緩存,發送統計數據等工做