獲取快取
1.匯入
#import "sdimagecache.h"
//把b單位轉換為m
[nsstring stringwithformat:@"%.2fm",(double)[[sdimagecache sharedimagecache] getsize]/1000/1000];
清除快取
[[sdimagecache sharedimagecache] cleardisk];
獲取某資料夾中所有檔案快取
//資料夾列舉器,可以列舉這個資料夾內以及這個資料夾的子資料夾中的所有檔案
nsdirectoryenumerator *enumerator = [[nsfilemanager defaultmanager] enumeratoratpath:<[commontool filedownloadpath]>>>需要遍歷的資料夾路經];
unsigned long long totalsize = 0;
while ([enumerator nextobject])
totalsize+=[[enumerator fileattributes] filesize];
[nsstring stringwithformat:@"%.2fm",(double)totalsize/1000/1000];
清理檔案快取
[[nsfilemanager defaultmanager] removeitematpath:<[commontool filedownloadpath]>>>需要刪除的資料夾路經 error:nil];
//push時自動隱藏tabbar
vc.hidesbottombarwhenpushed = yes;
自適應高度
cgrect rect = [_news.intr-需要獲取的字串- boundingrectwithsize:cgsizemake(screen_width-30>-需要多寬折行, 0) options:nsstringdrawinguseslinefragmentorigin|nsstringdrawingusesfontleading attributes:@ context:nil];
return rect.size.height+30;
獲取鍵盤的高度輸入框自適應
_inputview 是自定義的乙個 view 加上 textfield 的輸入框
[[nsnotificationcenter defaultcenter]addobserver:self selector:@selector(keyboardwillchangeframe:) name:uikeyboardwillchangeframenotification object:nil];
- (void)keyboardwillchangeframe:(nsnotification *)noti{
// nslog(@"%@",noti.userinfo);
cgrect rect = [[noti.userinfo objectforkey:uikeyboardframeenduserinfokey] cgrectvalue];
[uiview animatewithduration:[[noti.userinfo objectforkey:uikeyboardanimationdurationuserinfokey] floatvalue] animations:^{
_inputview.frame = cgrectmake(0, rect.origin.y-40, screen_width, 40);
_tableview.frame = cgrectmake(0, 0, screen_width, _inputview.frame.origin.y);
---用滑動方式讓鍵盤下去
-(void)scrollviewwillbegindragging:(uiscrollview *)scrollview{
[self.view endediting:yes];
氣泡聊天 專用 從某個畫素點拉申
self.bubbleimageview.image = [[uiimage imagenamed:@"bubbleself.png"] stretchableimagewithleftcapwidth:25 topcapheight:20];
//設定**為圓形 常用語頭像
self.headerimageview.layer.cornerradius = 30—**大小的半徑;
self.headerimageview.layer.maskstobounds = yes;
設定應用圖示的角標
iOS小知識點
1.nslog日誌列印 ifdef debug 除錯 define czlog nslog va args else 發布 define czlog endif 2.自定義導航欄後實現滑動返回功能 self interactivepopgesturerecognizer delegate nil 3...
IOS常見知識點
xcode 4.4 陣列和物件的訪問都可以簡寫了,例如賦值 array string 1 dic 取值 array 1 dic 1 早期的xcode編譯環境對方法順序要求很高,前面的函式體找不到後面的例項方法,發出警告,要麼只能在類別中宣告,多寫 要麼打亂函式順序,導致維護麻煩,新的llvm改變了以...
iOS面試知識點
現在進入本篇的正題。本篇的面試題是我認為比較好的ios開發基礎知識點,希望大家看過這後在理解的基礎上掌握而不是死記硬背。死記硬背很快也會忘記的。1.1 父類實現深拷貝時,子類如何實現深度拷貝。父類沒有實現深拷貝時,子類如何實現深度拷貝。1.2 kvo,nsnotification,delegate及...