zoukankan      html  css  js  c++  java
  • 传值 UI考试知识点

    传值:

    1. 属性传值:从前往后

    2. 代理传值:从后往前

    3. block:

    4. 单例:普通写法和GCD写法

    5 . 通知 NSNotification

    GCD 单例:

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

    知识点:

    1.

    UIView 继承于UIResponder,

    UIResponder继承于NSObject ,

    UIView可以响应用户事件,

    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];
  • 相关阅读:
    SaveFileDialog
    在SQL Server 2008中配置文件流(FILESTREAM)
    C#中图片转二进制到存储数据库
    OpenFileDialog
    WPF中自定义只能输入数字的TextBox
    QL Server 2008新特性:FILESTREAM
    ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
    winxp+Apache+Mysql+Python+Django安装配置
    django最佳实践
    Sphinx 在 windows 下安装使用
  • 原文地址:https://www.cnblogs.com/Evelyn-zn/p/4962707.html
Copyright © 2011-2022 走看看