0%

问题描述

在升级CocoaPods到1.8.X后,CocoaPods添加了CDN为默认的Spec repo源,而非原来以https://github.com/CocoaPods/Specs.git为默认source,来缓解git上的specs过大带来的效率下降问题。这个改动造成了我在家中pod install/update的时候无法正常运行。

提示错误:[!] CDN: trunk Repo update failed以及失败的pods列表

Read more »

问题描述

我们项目在语音发送用户评语时,使用了Lame三方库对客户端的pcm录音文件进行压缩,输出MP3文件。具体的Lame接入方法可以参考该文章 “iOS-Lame-Audio-transcoding“.

在iOS13的iPhoneX/iPhoneXS等iPhone机中出现录音边录边压缩时闪退的问题。

问题类型EXC_BAD_ACCESS野指正,对象过早被释放导致。

异常出现的位置在lame_encode_buffer_interleaved方法调用中,该方法为Lame提供的方法,且输入的参数也没有发现野指针存在。Zombie调试没有发现有用的信息。刚开始考虑是Lame库太老了(我们还在使用4年前的库😅),更新了Lame库没有解决问题。

尝试运行iOS-Lame-Audio-transcoding中提供的Demo,在我的设备中没有出现闪退现象。基本排除了Lame三方库的问题。

Read more »

问题描述

在使用SourceTree管理GitLab的时候出现了无法添加Repository

1
This is not a valid source path / URL

或者无法Pull or Push的情况。

1
2
remote: HTTP Basic: Access denied
fatal: Authentication failed for 'https://gitlab.xxx/xxx.git/'
Read more »

问题描述

在iOS9及以下版本中,WKWebView在自定义了他的scrollView.delegate为当前ViewController时,如果退出当前ViewController会闪退。提醒EXC_BAD_ACCESS错误并且闪退,

错误堆栈是-[UIScrollView(AdhocVisualEdit) adhoc_scrollViewSetDelegate:]

上一级是-[WKScrollView _updateDelegate]

Read more »

iOS开发实用工具

Chisel

一款由Facebook分享的丰富LLDB命令的开源工具,具体的安装方法和介绍参考官方github。

通过该工具我们可以快速定位当前显示的图层层级,展示任意UIImage /CGImageRef /UIView等对象的内容,显示某个对象的响应链等各种功能。大大提高我们在debug时的效率。尤其对于视图相关的问题,相比Xcode提供的Debug View Hierarchy功能,Chisel能提供更快速的响应和更加直观和针对性的显示。而Debug View Hierarchy则更加的形象。

最近发现的问题 “设置和捷径App内未列出自己App的Shortcut” 的解决办法在文章末尾

背景介绍

WWDC 2018 苹果更新了Siri使其支持Shortcuts功能,中文名“捷径”。支持用户通过自定义把一系列操作合并到一个Shortcut内。苹果官方应用提供了一些接口供Shortcut调用,如Map应用的“获取行程时间”,“显示路线”等。如果我们的应用需要支持,需要自己在App中开放可以被Shortcuts访问的接口。同时苹果正在大力推广这个Siri新功能,支持软件可在苹果App Store榜单“用 Siri,走捷径”中列出,有一定推广作用。该功能也有利于增加用户粘度和活跃人数。

Apple提供了官方关于Shortcuts的demo,但是在苹果大力推广Swift的浪潮下,demo的语言也是Swift版的,无奈公司现在还在使用Objc,下面介绍下Objc下的接入过程。

Read more »

最近在做iPad Pro适配时遇到了WKWebView图片显示不完全的坑

在显示网页中的大尺寸图片时,图片显示不完整,有些是下方不显示,有些是下方和右侧都不显示。流程如下

Read more »

问题描述

最近眼红WKWebView相对UIWebView的高可配置和高效。在最近的代码中选择使用WKWebView来加载JS动态页面。但是需要把WebView嵌入到另一个ScrollView中显示,所以需要拉伸到内容长度且不能被用户拖动。原始代码如下:

1
2
3
4
5
6
7
8
9
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
[webView evaluateJavaScript:@"document.body.scrollHeight" completionHandler:^(NSNumber *height, NSError * _Nullable error) {
float htmlHeight =[height floatValue];
CGRect webFrame = webView.frame;
webFrame.size.height = htmlHeight;
webView.frame = webFrame;
[self addFeedBackBtn];
}];
}

通过JS代码得到页面的高度。
但是这样的方法对于非静态页面无效,高度并非正确的高度。

Read more »

最近在把Python的定时程序放进Windows服务时遇到了上述的问题‘错误1053:服务没有及时响应启动或控制请求’ 或者 ‘Error 1053: The service did not respond to the start or control request in a timely fashion’。
可以正常安装python PythonFileName.py install
不能正常启动python PythonFileName.py start
尝试使用python PythonFileName.py debug检查代码,没有发现代码问题,考虑应该是环境问题。

最终在StackOverflow的 Can’t start Windows service written in Python (win32serviceutil) 中找到了 BuvinJ 的回答:“It might prove useful in this case to also add these directories to your system path: C:\Python27\Lib\site-packages\win32 and C:\Python27\Lib\site-packages\pywin32_system32. That will let you use pythonservice more easily. ”

解决办法

在cmd中输入
setx /M PATH "%PATH%;C:\Python27;C:\Users\Administrator\Anaconda2\Scripts;C:\Users\Administrator\Anaconda2\Lib\site-packages\pywin32_system32;C:\Users\Administrator\Anaconda2\Lib\site-packages\win32"
回车,增加两个路径的引用。然后就能启动服务了。

具体的Windows服务Python代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sys
import win32serviceutil
import win32service
import win32event
import servicemanager
import winerror

class StockRecommendRunLoop(win32serviceutil.ServiceFramework):
_svc_name_ = "StockRecommendRunLoop"
_svc_display_name_ = "Stock Recommend Run Loop"

def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)

def SvcDoRun(self):
self.ReportServiceStatus(win32service.SERVICE_RUNNING)
self.start_task()
win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)

if __name__ == '__main__':
if len(sys.argv) == 1:
try:
servicemanager.Initialize()
servicemanager.PrepareToHostSingle(StockRecommendRunLoop)
servicemanager.StartServiceCtrlDispatcher()
except win32service.error, details:
if details[0] == winerror.ERROR_FAILED_SERVICE_CONTROLLER_CONNECT:
win32serviceutil.usage()
else:
win32serviceutil.HandleCommandLine(StockRecommendRunLoop)

Reference:

Can’t start Windows service written in Python (win32serviceutil)
Python Windows Service的方式运行