ios问题记录

问题1.

     tableviewcell中图片没设置clip subviews,导致tableview在滑动时,图片重叠。设置下就可以了。

    注:Clip Subviews,只有在父视图范围内的子视图部分被绘制出来。如果未选中Clip Subviews,则全部子视图都将绘制出来,而不管它是否在父视图内部。

问题2.

   有关push跳转:

    push页面,返回到上一个页面,代码如下:

[self.navigationController popViewControllerAnimated:YES];

    返回父页面,代码如下:

[self.navigationController popToRootViewControllerAnimated:YES];

    返回指定页面,代码如下:

for (UIViewController *vc in self.navigationController.viewControllers) {
        if ([vc isKindOfClass:[MainViewController class]]) {
            MainViewController *mainVc = (MainViewController *)vc;
            [self.navigationController popToViewController:mainVc animated:YES];
        }
    }

问题3.

有一个界面把约束拖出到controller中了,只删除了controller中的约束属性,没有在stroryboard中删除关联的约束,有黄色警告。最终导致进到该界面就莫名的闪退。删除关联的约束就ok了。以后删除定义的关联属性,一定要先删除关联,再删除对应的属性。

问题4.

    判断NSDictionary是否为空,用NSNull

     if((NSNull *)commentDic != [NSNullnull]){...}

 

 问题5.

    UIAlertView进行push到下一个页面时,如果前一个页面有打开键盘,push到下一个界面可能有键盘出现。

问题6.

    ios9上面UILabel,约束后,并限制显示两行时,会出现只显示一行情况。把UILable设置   self.labIntroduce.preferredMaxLayoutWidth  = [UIScreenmainScreen].bounds.size.width - 30;

   就ok了。ios8没有这种问题。

问题7.

   xcode真机刷机时,报the identity used sign the executable is not longer valid.

   重新到开发者账户中,查看pp文件是否为无效

问题8.

   应用URL schema的定义:test://com.yican.test

   URL schema可以在safari浏览器上输入,打开应用。

 

问题9.

   添加支付宝sdk时,文件找不到。在header seach中添加路径。如下图:



 

问题10.

百度地图,引入相关包后,报编译问题。因为百度sdk中有c++,需修改编译方式。如下图:



 

 问题.11

 //TODO解决tableViewCell只显示有数据的分割线
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor clearColor];
    [self.searchTableView setTableFooterView:view];

 

问题.12

  UIWebView加载html代码,获取高度代码:

self.cellHeight = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"] floatValue];

 

问题.13

对数组中对象的某个字段进行排序。

NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:@"_listOrder" ascending:YES];
            hotCityArr = [[hotCityArr sortedArrayUsingDescriptors:[NSArray arrayWithObject:descriptor]] mutableCopy];

listOrder为对象中需排序的字段名称。

 

问题.14

//先搜索中文城市名
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"cityName LIKE[cd] %@",[NSString stringWithFormat:@"%@*",searchTxt]];

 

问题15.

//TODO处理加载更多消息位置问题
                NSIndexPath *indexPath = [NSIndexPath indexPathForRow:PAGE_NUM-1 inSection:0];
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                    [self.tableView reloadData];
                    [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
                });

 

问题16.

创建block匿名函数之前一般需要对self进行weak化,否则造成循环引用无法释放controller:
 __weak MyController *weakSelf = self 或者 __weak __typeof(self) weakSelf = self;
执行block方法体的时候也可以转换为强引用之后再使用:MyController* strongSelf = weakSelf; if (!strongSelf) { return; }

 

问题17.

   UIButton添加动画,当动画结束后,按钮颜色会变暗。解决访问可设置以下属性:

//TODO解决动画播放后,按钮颜色变暗问题
cell2.mediaBtn.adjustsImageWhenHighlighted = NO;

 

NSIndexPath *indexPath2 = [NSIndexPath indexPathForRow:_displayHomeVc.tagIndex inSection:4];
        HomeWorkTableViewCell *cell2 = (HomeWorkTableViewCell *)[_displayHomeVc.tableView cellForRowAtIndexPath:indexPath2];
        //TODO解决动画播放后,按钮颜色变暗问题
        cell2.mediaBtn.adjustsImageWhenHighlighted = NO;
        
        NSMutableArray  *arrayM=[NSMutableArray array];
        for (int i=1; i<5; i++) {
            [arrayM addObject:[UIImage imageNamed:[NSString stringWithFormat:@"topic-video-%d.png",i]]];
        }
        //设置动画数组
        [cell2.mediaBtn.imageView setAnimationImages:arrayM];
        //设置动画播放次数
        //    [_cell1.btnVideo.imageView setAnimationRepeatCount:10];
        //设置动画播放时间
        [cell2.mediaBtn.imageView setAnimationDuration:20*0.075];
        //开始动画
        [cell2.mediaBtn.imageView startAnimating];

 

问题18.  UIImageView进行图片旋转时,图片会出现毛边锯齿。设置以下属性可以解决,如下:

UIImageView *imgCustomized = [[UIImageView alloc] init];
imgCustomized.layer.allowsEdgeAntialiasing = YES;

 

 问题19.

   UIView设alpha透明度时,会把UIView中子控件也透明化,以下方法可以解决该问题:

self.viewB.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.45];

 

 

猜你喜欢

转载自wenxin2009.iteye.com/blog/2238308