1 、ios navigationcontroller 滑动返回
滑动返回是navigationcontroller默认返回按钮自带的功能,如果返回按钮自定义该功能失效,
解决的办法有两个:
①
self.navigationItem.backBarButtonItem = [[UIBarButtonItem
alloc]initWithCustomView:button];//这个方法用不了
只能用
self.navigationItem.backBarButtonItem =
[ [UIBarButtonItem alloc]initWithTitle: style: target: action:]
选择范围较小,
②
UIButton*button = [UIButton
buttonWithType:UIButtonTypeCustom];
[button setFrame:CGRectMake(0,
0, 40,
40)];
[button setTitle:@"返回"
forState:UIControlStateHighlighted];
[button setTitle:@"返回"
forState:UIControlStateNormal];
[button addTarget:self
action:@selector(back)
forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem*bar = [[UIBarButtonItem
alloc]initWithCustomView:button];
self.navigationItem.leftBarButtonItem = bar;
但是要在push之后加上
if ([self.navigationController
respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.delegate
= nil;
}
2、webview加载html图片自适应屏幕宽度
在用webview加载html的时候如果碰到html中有图片的时候,如果不对html做一下处理的话,会发现,加载出来的图片有些是对
屏幕不会自己适配的,这个时候处理的时候有两种方法,
①对webview做下处理,
self.mWebView.scalesPageToFit =
YES;
这个方法不完善,图片是会适配屏幕,但是字体会变小,
②写一个webview的拓展类
里面对html文本用js或者css做一下处理,添加一个一个head
[data_content appendString:@"<html>"];
[data_content appendString:@"<head>"];
[content appendString:@"<meta charset=\"utf-8\">"];
[content appendString:@"<meta id=\"viewport\" name=\"viewport\" content=\"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=false\"
/>"];
[content appendString:@"<meta name=\"apple-mobile-web-app-capable\" content=\"yes\" />"];
[content appendString:@"<meta name=\"apple-mobile-web-app-status-bar-style\" content=\"black\" />"];
[content appendString:@"<meta name=\"black\" name=\"apple-mobile-web-app-status-bar-style\" />"];
[content appendString:@"<style>img{width:100%;}</style>"];
[content appendString:@"<style>table{width:100%;}</style>"];
[content appendString:@"<title>webview</title>"];
这个处理的比较完美,也可以加在html的尾部,但是没有放在头部灵活,