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]);

  • 相关阅读:
    预备作业03 20162311张之睿
    [LeetCode 题解]: String to Interger (atoi)
    [LeetCode 题解]: Add Two Numbers
    [LeetCode 题解]: Interger to Roman
    [LeetCode 题解]: Longest Substring Without Repeating Characters
    [LeetCode 题解]: Roman to Interger
    [LeetCode 题解]: palindromes
    [LeetCode 题解]: Two Sum
    [LeetCode 题解]: Maximum Subarray
    [LeetCode 题解]:Gas Station
  • 原文地址:https://www.cnblogs.com/xiao-xiao-jian/p/5636016.html
Copyright © 2011-2022 走看看