更新列表
5th,August,2016
stringByAddingPercentEscapesUsingEncoding
Deprecated in iOS9.0:
urlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
Updated:
[urlStr stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
31st,August,2016
UIAlertView
Deprecated in iOS9.0:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"超出100字限制" message:@"" delegate:nil cancelButtonTitle:@"知道了" otherButtonTitles: nil];
[alert show];
Updated:
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"超出100字限制" message:nil preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"知道了" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
1st,Nov,2016
setStatusBarHidden
隐藏导航栏
Deprecated in iOS9.0:
[[UIApplication sharedApplication] setStatusBarHidden:YES];
Updated:
“Use -[UIViewController prefersStatusBarHidden]”
// 在对应的viewController中重写该方法,返回YES.默认返回为NO,即不应藏导航栏
- (BOOL)prefersStatusBarHidden {
return YES;
}
2rd,Nov,2016
计算文本高度
Deprecated in iOS7.0:
CGSize size = [strText sizeWithFont: textView.font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
CGFloat height = size.height;
Updated:
- (float)heightForTextView:(UITextView *)textView {
float fPadding = 8.0;
CGSize constraint = CGSizeMake(textView.contentSize.width - fPadding*2 - 30*2, MAXFLOAT);
CGRect rect = [textView.text boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:textView.font,NSFontAttributeName, nil] context:nil];
float fHeight = rect.size.height + 16.0;
return fHeight;
}
持续更新中…