iOS 小技巧总结

上传App Store x86_64, i386 错误

在集成了环信的即时通讯SDK后上传App Store报了x86_64, i386错误,由于手机的cpu和模拟器即电脑的cpu指令集存在差异,环信为了能让动态库可以直接在模拟器上和真机上直接运行从而兼容了x86_64, i386 ,但App Store上传的时候是不需要兼容x86_64, i386 指令集的动态库,所以去除就好了。

解决方法

project ->Build Phases ->Run Script(没有自己添加一项)

添加如下脚本(加入后使用Pod会报错,Pod的时候去掉就可以)

APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
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

解决长按事件的两次相应

-(void)longClick:(UILongPressGestureRecognizer *)gestureRecognizer{
    
    if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
        if (self.longClickBlock) {
            self.longClickBlock();
        }
    }  
}

应用上架重名问题

有版权的可以输入名称后进入申诉的入口,进行申诉即可。
没有版权的直接加几个其它字符即可,应用在手机上显示的名字可以和App Store上的不同。
如:有道词典-全能单词助手

字符串显示%字符

错误方式

self.labelErrorPercent.text=[NSString stringWithFormat:@"%@/%",[check objectForKey:@"RATE"]];

正确方式

self.labelErrorPercent.text=[NSString stringWithFormat:@"%@%@",[check objectForKey:@"RATE"],@"%"];

Cordova 打包无法找到相关文件

project->Build Settings->Head Search Path

加入以下代码

$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include

Pod 编译报错:bad interpreter: Operation not permitted

PodFile文件中的项目移除,执行pod install命令移除原有项目资源。
再将PodFile文件中的项目加入,执行pod install加入项目资源编辑错误就没有了

视频转换报未知错误小记

在将.mov格式文件转换成.mp4文件格式的时候总是报未知错误.最后发现是NSUrl的问题.
在做这样文件保存到沙盒功能的时候,使用的NSUrl一定得这样获取

[NSURL fileURLWithPath:savePath];

不要使用

[NSURL URLWithString:savePath];

Facebook 第三方登录获取用户信息

对应的权限 : https://developers.facebook.com/docs/facebook-login/permissions

获取对应参数:https://developers.facebook.com/tools/explorer/1474048672701063?method=GET&path=me%3Ffields%3Did%2Cname%2Cbirthday&version=v2.12

    [FBSDKProfile enableUpdatesOnAccessTokenChange:YES];
    [FBSDKAccessToken setCurrentAccessToken:nil];
    FBSDKLoginManager * mananger=[FBSDKLoginManager new];
    mananger.loginBehavior=FBSDKLoginBehaviorNative;
    //添加public_profile,user_about_me,user_birthday三个权限
    [mananger logInWithReadPermissions:@[@"public_profile",@"user_about_me",@"user_birthday"] fromViewController:vc handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
       //获取对应用户信息的字段,这里需要注意的是有些信息必须要获取权限了才能获取,比如生日.
        NSDictionary*params= @{@"fields":@"id,name,email,age_range,first_name,last_name,link,gender,locale,picture,timezone,updated_time,verified,birthday"};
        FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                      initWithGraphPath:result.token.userID
                                      parameters:params
                                      HTTPMethod:@"GET"];
        [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
            NSLog(@"%@",result);
            
        }];
        
//        [self sendInfo:vc type:2];
    }];

UITableView、UIScrollView中的UIButton高亮效果延时解决方法

self.tableView.delaysContentTouches = NO;

继承父类,使用父类xib

子类中添加如下代码

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:NSStringFromClass([self.superclass class]) bundle:nibBundleOrNil];
    return self;
}

TextView 边距设置

self.textContainerInset=UIEdgeInsetsMake(16, 16, 16, 16);

打开应用到App Store评分界面

NSString  * nsStringToOpen = [NSString  stringWithFormat: @"itms-apps://itunes.apple.com/app/id%@?action=write-review",@"1014939463"];//替换为对应的APPID
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:nsStringToOpen]];

Pod 无法搜索到相应的库

首先同步本地数据
pod setup

删除本地搜索文件,接着继续搜索即可
rm ~/Library/Caches/CocoaPods/search_index.json

scrollView 滑动代理记录


- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;{
    BTLog(@"%@",@"开始移动");
}
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{
    BTLog(@"%@",@"将要结束移动");
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
    NSString * str =decelerate?@"需要减速":@"不需要减速";
    BTLog(@"结束移动,%@减速:,后面有详细说明",str);
}

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView{
    BTLog(@"%@",@"将要开始减速");
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    BTLog(@"%@",@"结束减速");
}
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView{
    BTLog(@"%@",@"结束了滚动动画");
    
}

使VC从状态栏开始布局

    self.edgesForExtendedLayout = UIRectEdgeAll;
    if (@available(iOS 13.0, *)) {
        self.scrollView.automaticallyAdjustsScrollIndicatorInsets = NO;
    } else {
        
    }
    self.extendedLayoutIncludesOpaqueBars = YES;

打开沙盒暴露documents文件夹到finder

info.plistApplication supports iTunes file sharingYES

你可能感兴趣的:(iOS 小技巧总结)