开发常用

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

转载于:https://www.cnblogs.com/xiao-xiao-jian/p/5636016.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值