Skip to content

Instantly share code, notes, and snippets.

View shiablue's full-sized avatar

Oliver Xia shiablue

  • M35
  • Shenzhen
View GitHub Profile
@shiablue
shiablue / keyevents.json
Created April 11, 2024 06:00 — forked from arjunv/keyevents.json
All Android Key Events for usage with adb shell
{
"key_events": {
"key_unknown": "adb shell input keyevent 0",
"key_soft_left": "adb shell input keyevent 1",
"key_soft_right": "adb shell input keyevent 2",
"key_home": "adb shell input keyevent 3",
"key_back": "adb shell input keyevent 4",
"key_call": "adb shell input keyevent 5",
"key_endcall": "adb shell input keyevent 6",
"key_0": "adb shell input keyevent 7",
@shiablue
shiablue / post_form_data.m
Created April 26, 2023 02:27 — forked from juwencheng/post_form_data.m
POST multipart/form-data with Objective-C| 同时上传多张图片和参数的方式 Objective-C/Swift
- (NSData *)createBodyWithBoundary:(NSString *)boundary
parameters:(NSDictionary *)parameters
paths:(NSArray *)paths
fieldName:(NSString *)fieldName {
NSMutableData *httpBody = [NSMutableData data];
// add params (all params are strings)
[parameters enumerateKeysAndObjectsUsingBlock:^(NSString *parameterKey, NSString *parameterValue, BOOL *stop) {
[httpBody appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
@shiablue
shiablue / .editorconfig
Created April 3, 2023 09:46
C# code style config
root = true
# All files
[*]
indent_style = space
# Xml files
[*.xml]
indent_size = 4
@shiablue
shiablue / mac-clear-icon-cache.sh
Created November 10, 2022 02:26 — forked from ismyrnow/mac-clear-icon-cache.sh
Clear the icon cache on a Mac when you start seeing generic icons in Finder or the Dock
sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder

Note

Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

Updates

  • [UPDATE 4] iOS 10 update: apparently settings now can be reached using App-Pref instead of prefs
  • [UPDATE 3] For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached
  • [UPDATE 2] The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead
  • [UPDATE 1] Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.

有时候,因为权限等问题,我们需要让用户可以在APP内直接通过点击确认跳转到系统设置中的某个条目或者当前APP设置信息去修改一些内容。

iOS8以下开放了这个语句用于跳转:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

这个语句iOS 10以上也是适用的,可惜只能跳到设置界面,而不能进入详细的条目中。 要怎么做到精确跳转呢?

Fix ERROR ITMS-90096

因为项目需要进行多国语言支持且最低支持iOS 9所以需要在info.plist里头定义UILaunchImages的时候加了下面的内容:

<key>UILaunchImageMinimumOSVersion</key>
<string>9.0</string>

然后上传App Store无论怎么修改都会出现下面的错误提示:

+ (instancetype)findBestViewController:(UIViewController *)vc {
    if (vc.presentedViewController) {
        // Return presented view controller
        return [UIViewController findBestViewController:vc.presentedViewController];
    } else if ([vc isKindOfClass:[UISplitViewController class]]) {
        // Return right hand side
        UISplitViewController* svc = (UISplitViewController*) vc;
        if (svc.viewControllers.count > 0) {
            return [UIViewController findBestViewController:svc.viewControllers.lastObject];
@shiablue
shiablue / fix_lockdown.md
Last active February 1, 2021 23:10
修复误删lockdown文件夹后无法识别iPhone的问题。

修复误删 /private/var/db/lockdown 后导致的识别不了iPhone的问题。

  1. 先创建lockdown文件夹,并修改权限为700
    cd /var/db
    sudo mkdir lockdown
    sudo chmod 700 lockdown
    
  2. 设置lockdown文件夹所属组、所属用户

Mac OS 10.12 之后打开任何来源的应用

sudo spctl --master-disable