傳值 UI考試知識點

傳值:

1. 屬性傳值:從前日後sql

2. 代理傳值:從後往前數據庫

3. block:spa

4. 單例:普通寫法和GCD寫法代理

5 . 通知 NSNotificationcode

 

GCD 單例:sqlite

static PlayMusicHelp *share = nil;

+ (PlayMusicHelp *)shareData {
    if (share == nil) {
        static dispatch_once_t haha;
        dispatch_once(&haha, ^{
            share = [[PlayMusicHelp alloc] init];
        });
    }
    return share;
}

 

知識點:

1.blog

UIView 繼承於UIResponder,繼承

UIResponder繼承於NSObject ,事件

UIView能夠響應用戶事件,string

CALayer用來繪製內容

2. storyboard:設置cell的自適應高度:

self.tableView.estimatedRowHeight = 44.0f;
self.tableView.rowHeight = UITableViewAutomaticDimension;

3. 本地已存在數據庫文件  如何獲取:

// 獲取指定路徑的數據庫文件:
    NSString *document = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
    NSString *filePath = [document stringByAppendingPathComponent:@"團購數據"];
    NSString *savePath = [filePath stringByAppendingPathComponent:@"Display.sqlite"];
    if ([[NSFileManager defaultManager]fileExistsAtPath:savePath]) {
        self.db = [FMDatabase databaseWithPath:savePath];
    }

獲取完以後,賦給self.db 而後就能夠讀取數據庫裏的數據了(經過self.db) 斷網的狀況下  也能夠讀取。

4. 將中文進行轉碼:

NSString *encodedValue2 = [str2 stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];

5. 計算label高度:

// 計算文字高度 類方法
+(CGFloat)cellHeight:(NSString *)string {
    CGSize size = CGSizeMake(220, 1000);
    NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:17] forKey:NSFontAttributeName];
    
    CGRect rect = [string boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    return rect.size.height;
}

6. 指定路徑下建立文件夾:

// 1. 建立存儲數據的文件夾 :團購數據
    NSString *document = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
    NSLog(@"文件儲存路徑:%@", document);
    NSFileManager *manager = [NSFileManager defaultManager];
    NSString *filePath = [document stringByAppendingPathComponent:@"團購數據"];
    [manager createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];
相關文章
相關標籤/搜索