iOS11 UIScrollView 偏移量问题 做项目的时候发现UIScrollView 回弹有问题,不能回弹到原来的位置,只能到状态栏下面,在此记录下 主要是 iOS11 新增的 contentInsetAdjustmentBehavior 改成下面的就可以了 if (@available(iOS 11.0, *)) { _scrollView.contentInsetAdjustmentBehavior = UIScrol
Android部分手机自定义Dialog顶部有条蓝色的线问题 这个问题在很多手机上看不到,在一款三星的手机(手机型号记不住了..)上遇到过,这里记录下解决方法通常定义一个对话框都会修改其Style,如下,但这样在那一部三星的手机上顶部会有一条蓝色的线) <style name="BottomDialog" parent="AlertDialog.AppCompat"> <item name="android:windowIsFloating"
Android 动态代理 Java动态代理只支持Interface,可以控制对象的访问看一个例子:上面定义了一个接口Animal和实现类Dog,接下里看重点ProxyHandler 使用动态代理的关键就是要实现InvocationHandler,在ProxyHandler 中定义了一个回调ProxyCallBack,方便调用使用运行结果如下如果注释掉ProxyHandler中的method.invoke(target, a
Retrofit缓存 public static OkHttpClient genericClient() { if (client != null) { return client; } //缓存路径 File cacheFile = new File(App.getContext().getCacheDir(), "HttpCac
ScrollView嵌套ListView或者RecyclerView时默认滑动一段距离问题 ScrollView嵌套ListView或者RecyclerView时,当列表视图上还有视图的时候,这些视图可能默认会被滑过,导致ScrollView显示出来就是列表视图的位置解决也很简单,在上面的视图布局添加 android:focusable="true" android:focusableInTouchMode="true"
分享一个回弹插值器 效果如下代码class MyBounceInterpolator implements Interpolator { double defaultAmplitude = 0.3f; double defaultFrequency = 6; public MyBounceInterpolator() { }
leakcanary 检测内存泄漏 leakcanary https://github.com/square/leakcanaryA,B两个Activity,A跳转到B,B用CountDownTimer计时,并且不做取消处理,然后立刻返回到A先初始化LeakCanarypublic class App extends Application {@Overridepublic void onCreate() {
Android不规则形状点击检测 public class TouchRegionView extends View { Paint paint = new Paint(); //主要是Region ,region存储了圆的Path Region circleRegion;//圆的Region Path circlePath;//圆的path public TouchRegionView(Contex
AndroidStudio 用正式签名调试应用 1.打开app/build.gradle// 2.在android配置下添加 signingConfigs { debug { storePassword "密码" keyAlias "别名" keyPassword "别名密码" storeFile file("keystore路径") }}
Android 简单实现流式布局 上代码public class FlowLayout extends ViewGroup { public FlowLayout(Context context) { super(context); } public FlowLayout(Context context, AttributeSet attrs) { super(context, att
Android轻松实现ListView下拉放大 先上图自定义ListView代码public class AListView extends ListView { final String TAG = "AListView"; private ImageView headerImage; private int headerHeight; public AListView(Context context) {
CocoaPod 版本升级 淘宝的镜像好像用不了了,换成https也不行查看当前的ruby 镜像gem sources -l移除当前的ruby镜像 gem sources --remove https://ruby.taobao.org/添加一个新的ruby镜像gem sources -a https://gems.ruby-china.org/安装 CocoaPodsudo gem install -n /usr/loca
Android 透明状态栏 //沉浸状态栏 4.4if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);}//透明状态栏 5.0if (Build.VERSI
Android 加载其他Apk中的资源文件 public Drawable loadApkResources(String apkPath) { try { //获取apk的资源 最终都要通过AssetManager 获取, getAssets() 获取的AssetManager是获取的本身Apk的 //获取其他Apk的资源需要实例化一个AssetManager,并把该AssetManager的加载路径修
Android 加载其他Apk中的类方法 注意读写SD卡的权限问题public void loadApkClass(String apkPath, Context context) { //app路径下的文件夹名称 File dexOutputDir = context.getDir("dex", 0); //被加载的Class String className = "com.mz.testapk.TestClas
iOS 极光推送设置别名 //登录 [JPUSHService setTags:nil alias:userNmae callbackSelector:@selector(tagsAliasCallback:tags:alias:) object:self];- (void)tagsAliasCallback:(int)iResCode tags:(NSSet*)tags alias:(NSString*)alias {
透明的ViewController UINavigationController*navi = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailNavi"]; WishDetailViewController* wishDetail = [navi childViewControllers][0]; wishDetail.isSelf
SearchBar颜色去除 mySearchBar.backgroundColor = RGBACOLOR(249,249,249,1); mySearchBar.backgroundImage = [self imageWithColor:[UIColor clearColor] size:mySearchBar.bounds.size]; //取消searchbar背景色- (UIImage *)imageWit
View坐标转换 // 将像素point由point所在视图转换到目标视图view中,返回在目标视图view中的像素值- (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view;// 将像素point从view中转换到当前视图中,返回在当前视图中的像素值- (CGPoint)convertPoint:(CGPoint)point fromView:(UI
检查设备权限 + (BOOL)havePhotoLibraryPermission{ ALAuthorizationStatus author = [ALAssetsLibrary authorizationStatus]; if (author == kCLAuthorizationStatusRestricted || author ==kCLAuthorizationStatusDenied)