iOS 小知识集合

关于 NSData的 ReadingOptions

如果App中需要获取占用内存过大的对象,建议使用映射的方式引用该对象,防止内存占用.

 public struct ReadingOptions : OptionSet {

        public init(rawValue: UInt)

        
        public static var mappedIfSafe: NSData.ReadingOptions { get } // Hint to map the file in if possible and safe

        public static var uncached: NSData.ReadingOptions { get } // Hint to get the file not to be cached in the kernel

        @available(iOS 5.0, *)
        public static var alwaysMapped: NSData.ReadingOptions { get } // Hint to map the file in if possible. This takes precedence over NSDataReadingMappedIfSafe if both are given.

        
        // Options with old names for NSData reading methods. Please stop using these old names. 废弃
        public static var dataReadingMapped: NSData.ReadingOptions { get } // Deprecated name for NSDataReadingMappedIfSafe

        public static var mappedRead: NSData.ReadingOptions { get } // Deprecated name for NSDataReadingMapped 废弃

        public static var uncachedRead: NSData.ReadingOptions { get } // Deprecated name for NSDataReadingUncached 废弃
    }

复制代码

Cell边缘线的设置小方法


#define  kMarginX 15

#define LINE_HEIGHT  0.25

#define VERTICAL_LINE_MARGIN  20

- (void)setupUI{
    
    __weak typeof(self) weakSelf = self;
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.leftLineView];
    [self.contentView addSubview:self.rightLineView];
    [self.contentView addSubview:self.topLineView];
    [self.contentView addSubview:self.bottomLineView];

    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.contentView.mas_left).offset(kMarginX);
        make.right.equalTo(weakSelf.contentView.mas_right).offset(-kMarginX);
        make.centerY.equalTo(weakSelf.contentView.mas_centerY);
    }];
    
    [self.topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.equalTo(weakSelf.contentView);
        make.height.mas_equalTo(LINE_HEIGHT);
    }];
    
    
    [self.leftLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.centerY.equalTo(weakSelf.contentView);
        make.width.mas_equalTo(LINE_HEIGHT);
        make.top.equalTo(weakSelf.contentView).offset(VERTICAL_LINE_MARGIN);
    }];
    
    [self.rightLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(weakSelf.contentView);
        make.width.mas_equalTo(LINE_HEIGHT);
        make.top.equalTo(weakSelf.contentView).offset(VERTICAL_LINE_MARGIN);
        make.right.equalTo(weakSelf.contentView).offset(LINE_HEIGHT);
    }];
    
    [self.bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf.contentView);
        make.bottom.equalTo(weakSelf.contentView).offset(LINE_HEIGHT);
        make.height.mas_equalTo(LINE_HEIGHT);
    }];
    
    
}

-(UIView *)leftLineView{
    if (_leftLineView == nil) {
        _leftLineView = [UIView new];
        _leftLineView.backgroundColor = [UIColor colorWithHex:@"#CACACA"];
    }
    return _leftLineView;
}

复制代码

这样cell如果周围有衔接,可以将连接处的边缘线覆盖,给人的错觉就是 粗细都是一样的 哈哈

Group 样式的 tableView ,设置 sectionFooter 失效的原因

应用场景: section 中 有时业务逻辑需要, 设置不同的 sectionFooter 高度, 有的 section 有 footer, 有的没有 ,当不需要 section 中的 footer 的话, 设置 height 为 0 是没有作用的,使用 reveal发现 理应高度为 0 的, 总是 显示高度为 17.3333; 解决办法, 返回 CGFLOAT_MIN ,也就是 最接近0 的浮点数. 估计是苹果底层的 数据类型问题

-(CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section
{
    // 照片(1) - 关注(1) - 评论总数(1) - 评论的列表(多)
    if (section == 0) { // 照片
        return CGFLOAT_MIN;
    }
    
    { // section1没有cell 只有 headerView
        
        if (self.data.focusUsers.count > 0) { // 有关注的分组
            if (section == 1 || section == 2) { // 关注 - 评论总数

                return CGFLOAT_MIN;
            } else{
                // 根据有无关注 取值
                ArtCommentList *listModel   = self.commentResult.listArray[section];
                
                return listModel.sectionFooterHeight;
            }
        }
        
        
        {// 没有 关注的分组
            
            if (section == 1) {
                return CGFLOAT_MIN;
            } else{
                // 根据有无关注 取值;
                ArtCommentList *listModel   = self.commentResult.listArray[section];
                return listModel.sectionFooterHeight;
            }
            
        }
        //end
    }

}
复制代码

contains unsupported architecture

如何解决Unsupported Architecture. Your executable contains unsupported architecture '[x86_64, i386]

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"

# This script loops through the frameworks embedded in the application and

# removes unused architectures.

find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK

do

FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)

FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"

echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"

EXTRACTED_ARCHS=()

for ARCH in $ARCHS

do

echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"

lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"

EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")

done

echo "Merging extracted architectures: ${ARCHS}"

lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"

rm "${EXTRACTED_ARCHS[@]}"

echo "Replacing original executable with thinned version"

rm "$FRAMEWORK_EXECUTABLE_PATH"

mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"

done
复制代码

微信分享的问题

  1. 分享的内容详情有长度限制(包括安卓和iOS), 如果过程,即便调用了微信的API,你会发现 appDelegate中关于应用相互调用的API并没有走,而简化分享的内容详情长度后就可以正常调用. 解决方法有 移动端封装分享工具,写一个共有的方法过滤截取内容分享详情的长度, 或者后台传递分享内容的时候处理这些相关的限制(不推荐,工作量太大)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值