zoukankan      html  css  js  c++  java
  • 开发常用

    @font-face { font-family: "宋体"; }@font-face { font-family: "宋体"; }@font-face { font-family: "@宋体"; }@font-face { font-family: "Cambria"; }p.MsoNormal, li.MsoNormal, div.MsoNormal { margin: 0cm 0cm 0.0001pt; text-align: justify; font-size: 12pt; font-family: Cambria; }.MsoChpDefault { font-family: Cambria; }div.WordSection1 { }

    textView自适应高度

    -(void)textViewDidChange:(UITextView *)textView{

        CGFloat h = 0;

        if (textView.text.length == 0) {

            h = 30;

        }else{

           

            h = textView.contentSize.height;

        }

        CGRect temp = textView.frame;

        temp.size.height = h;

    textView.frame = temp;

    }

    计算文字高度

    - (CGFloat)stringHeight:(NSString *)aString

    {

        // 计算文字高度

        CGRect r = [aString boundingRectWithSize:CGSizeMake([[UIScreen mainScreen] bounds].size.width - 20, 2000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14.0f]} context:nil];

       

        return r.size.height;

    }

    输入框键盘上完成收键盘

    UIView *iv = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 40)];

        iv.backgroundColor = [UIColor colorWithRed:210 / 255.0 green:213 / 255.0 blue:220 / 255.0 alpha:1];

        UIButton *textFieldSureButton = [UIButton buttonWithType:(UIButtonTypeSystem)];

        textFieldSureButton.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 50, 0, 50, 40);

        [textFieldSureButton setTitle:@"完成" forState:(UIControlStateNormal)];

        [textFieldSureButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];

        [textFieldSureButton addTarget:self action:@selector(dissmissKeyBoard) forControlEvents:(UIControlEventTouchUpInside)];

        [iv addSubview:textFieldSureButton];

       

    textView.inputAccessoryView = iv;

    textView.delegate=self;

    方法

    -(void)dissmissKeyBoard{

        [textView resignFirstResponder];

     

    }

    //***获取字符串

     

     

     

        NSString *str=tf.text;

     

    //***调用关键方法,获得bool值,yes或者no:

     

      BOOL ok= [self isIncludeSpecialCharact:str];

     

        if (ok==YES) {

     

            NSLog(@"包含有特殊字符");

     

        }else{

     

            NSLog(@"不包含特殊字符");

     

        }

     

    //***关键方法

     

     

     

    -(BOOL)isIncludeSpecialCharact: (NSString *)str {

     

    //***需要过滤的特殊字符:~¥#&*<>《》()[]{}【】^@/£¤¥|§¨「」『』¢¬ ̄~@#¥&*()——+|《》$_€。

     

        NSRange urgentRange = [str rangeOfCharacterFromSet: [NSCharacterSet characterSetWithCharactersInString: @"~¥#&*<>《》()[]{}【】^@/£¤¥|§¨「」『』¢¬ ̄~@#¥&*()——+|《》$_€"]];

     

        if (urgentRange.location == NSNotFound)

     

        {

     

            return NO;

     

        }   

     

        return YES;

     

    }

    字典变json

    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dic options:0 error:nil];

     NSLog(@"%@",[[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]);

  • 相关阅读:
    微服务架构技术栈选型手册(万字长文)
    Visual Studio 2013 always switches source control plugin to Git and disconnect TFS
    Visual Studio 2013 always switches source control plugin to Git and disconnect TFS
    MFC对话框中使用CHtmlEditCtrl
    ATL开发 ActiveX控件的 inf文件模板
    ActiveX: 如何用.inf和.ocx文件生成cab文件
    Xslt 1.0中使用Array
    如何分隔两个base64字符串?
    An attempt was made to load a program with an incorrect format
    JQuery 公网 CDN
  • 原文地址:https://www.cnblogs.com/xiao-xiao-jian/p/5636016.html
Copyright © 2011-2022 走看看