zoukankan      html  css  js  c++  java
  • iOS开发中遇到的一些问题以及解决办法总结

    1.IOS7导航栏上的自定义的图标会被改动颜色,为了去除这个默认颜色,解决方案如下:

    http://stackoverflow.com/questions/19372269/uibarbuttonitem-with-uiimage-always-tinted-ios-7

    2.IOS导航栏可以自定义buttonbaritem,这样就可以更改item的位置了

    http://stackoverflow.com/questions/5761183/change-position-of-uibarbuttonitem-in-uinavigationbar

    3.IOS8中,把uiscrollview 跟autolayout一起来做,问题有一堆,要好好的研究一下了

       参考了几篇有价值的博文,发现自己似乎会了:

    http://blog.csdn.net/kmyhy/article/details/39929117   

    http://mobileoop.com/auto-layout-advanced-techniques-for-ios-8-and-7-using-xcode-6-on-storyboard

    4.IOS8的uiscrollview 跟autolayout一起,有一个bug:uiscrollview的上方会被无缘无故增加64px!这个的确是iOS8的bug,下面是解决办法:

    http://stackoverflow.com/questions/26047595/extra-top-white-space-since-ios-8-using-autolayout-and-scrollview

    http://stackoverflow.com/questions/25954831/issue-with-auto-layout-on-ios-8-code-works-perfectly-on-ios-7?lq=1

    总结一下:在viewDidload函数中添加代码:

    [self.viewsetNeedsLayout];

    就行了(这个问题解决办法其实是问题13,而不是上面的解决方法,请改正)

    5.IOS 如何去除导航栏最下面的一条黑色的线,使用如下方式:

    + (UIImage *)imageWithColor:(UIColor *)color { CGRect rect = CGRectMake(0.0f, 0.0f,1.0f, 1.0f); UIGraphicsBeginImageContext(rect.size); CGContextRef context =UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(context, [color CGColor]);CGContextFillRect(context, rect); UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return theImage; }
    然后:
    
    
    [self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:[UIColorclearColor]]];即可

    6.给UIView设置边框border,并且是圆角边框带阴影,代码如下:(不要忘了引入QuartzCore框架

    [v.layer setCornerRadius:30.0f]; // border [v.layer setBorderColor:[UIColorlightGrayColor].CGColor]; [v.layer setBorderWidth:1.5f]; // drop shadow [v.layer setShadowColor:[UIColor blackColor].CGColor]; [v.layer setShadowOpacity:0.8]; [v.layer setShadowRadius:3.0]; [v.layer setShadowOffset:CGSizeMake(2.0, 2.0)];

    7.在storyboard中,设置uilabel的宽度随着文字宽度变化而变化

         操作方法:选中该UIlabel,然后选中菜单"Editor"->"size to fit content" ,该设置项适用于label uiimageview等

    8.Xcode 6.1 中,在storyboard中添加一个uitableview ,然后添加一个自定义的uitableviewcell,然后往uitableviewcell的content中拖拽各种元素,我发现,当我用鼠标调整某个组件(UIImageView或者UILabel的大小的时候),其他的uilabel或者uiimageview 或者uiview的frame就被设置为了(0,0,0,0)了,太揪心了,正在查找解决方案中:

    9.对于uitableview,如果想去掉每条记录点击的时候,颜色的有变化,可以参考如下解决方案,有多种:

            1. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];

    2.[tableView setAllowsSelection:NO];

    3.[cell setUserInteractionEnabled:NO];

       4.[tableView setUserInteractionEnabled:NO];

    10.如何设置APP的显示名称

         选择项目名称->Build Settings 搜索product name  然后就在packaging这个节点下面发现了product name这个设置项,设置一下就可以了

    11.项目中需要使用弹出菜单的方式来进行筛选,于是从网上找了一个开源库:kxMenu,发现很好用,但是当我把source文件夹下面的KxMenu.h和KxMenu.m拷贝到xcode6新建的项目的时候,发现了如下报错:

          property with 'strong ' attriute must be of object type 以及 Unkown Uiimage type,仔细观察发现原来是在头文件中没有包含对的import,添加上面import代码,编译通过~~

    12.最近在做一个图片上传(拍照、相册多图上传)功能模块,发现下面有个哥们关于UIImage的使用整理挺全面,值得借鉴一下:

          http://www.cnblogs.com/smileEvday/archive/2013/05/14/uiimage.html

    13.当我把uitextview控件拖拽到storyboard的时候,我发现总会有大概64px的空白区域在顶部,很丑。原来问题是在于IOS7以后,会对uiscrollview默认加上64px的inset,额···好吧,真是醉了,解决办法如下:

    uiviewcontroller里面实现这个方法:automaticallyAdjustsScrollViewInsets 返回值NO就OK

    14.完美解决uiview在uicotrollerview的底部,随着键盘高度的变化,不断的调整高度的方法:

              - (void)keyboardWillShow:(NSNotification *)notification
    {
        NSDictionary *userInfo = [notification userInfo];
        NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];
        
        CGRect keyboardRect = [aValue CGRectValue];
        keyboardRect = [self.view convertRect:keyboardRect fromView:nil];
        
        NSValue *animationDurationValue = [userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey];
        NSTimeInterval animationDuration;
        [animationDurationValue getValue:&animationDuration];
        
        [UIView animateWithDuration:animationDuration
                         animations:^{
                             _menuViewBottom.constant -= _keyboardHeight;
                             _menuViewBottom.constant += keyboardRect.size.height;
                             
                             _keyboardHeight = keyboardRect.size.height;
                         }];


        
    }

        - (void)keyboardWillHide:(NSNotification *)notification
    {
        
         NSTimeInterval animationDuration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
        
        [UIView animateWithDuration:animationDuration
                         animations:^{
                             _menuViewBottom.constant -= _keyboardHeight;
                             [_menuView layoutIfNeeded];
                             _keyboardHeight = 0;
                         }];
    }

  • 相关阅读:
    Django中间件
    cookies与session
    Django Form组件
    Django 自定义分页器
    Django 批量插入数据
    Ajax
    图书管理系统
    Django常用字段及参数、事务、数据库查询优化
    Django之F与Q查询
    课堂测试-统计单词个数和字母出现频率
  • 原文地址:https://www.cnblogs.com/includeao/p/7690081.html
Copyright © 2011-2022 走看看