我在同一个UINavigationController中提供了两个UIView; 查看A和视图B.
在转换过程中,因为我想应用一些自定义动画样式,我想知道UINavigationController中演示文稿进度的百分比.我该怎么做呢?
我想要一个这样的函数:
class ExampleNavigationController: UINavigationController {
func viewControllerMoves(from: UIViewController, to: UIViewController, progress: CGFloat) {
//I can read here how far the animation is and apply custom animation styles
}
}
Run Code Online (Sandbox Code Playgroud)
在用户更新期间也应调用此函数:示例 - > http://www.latet.nl/appvideo.mov
我该怎么做呢?
示例屏幕
百分比为0.50
百分比为1.00
百分比为0.00
transition uinavigationcontroller ios presentviewcontroller swift
使用 Alamofire,是否有可能在下载完整文件之前有一个函数来处理标头响应?
例如:
我们的应用程序在多个页面上使用相同的元素。这些元素是使用请求收集的。每个请求都有自己的哈希值(md5 校验和)。我们在标头中发送此哈希值,如果缓存系统中识别出该哈希值,我想中止请求。
示例实现
APIManager.sharedManager.request(url, method: method, parameters: parameters)
.doSomethingHere {
//I want to read the headers here, before the data is fetched from the server.
//There needs to be an option here to cancel the request.
}
.responseJSON { response in
//If the request isn't cancel in the function above. The data should be here.
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:解决方案(Alamofire 实施 SWIFT 3)
APIManager.sharedManager.delegate.dataTaskDidReceiveResponse =
{(session:URLSession, dataTask:URLSessionDataTask, response:URLResponse) -> URLSession.ResponseDisposition in
if let httpResponse = response as? HTTPURLResponse { …Run Code Online (Sandbox Code Playgroud) 题
我将我的项目升级到Swift 3.0,但在更新后,应用程序将无法在模拟器上运行.它不会崩溃,而只是冻结.
我调查了这个问题,看到应用程序挂起了自定义字体的初始化.
我复制了下面的功能.
func registerMaterialFont() {
let url = Bundle.main.url(forResource: "Material-Design-Iconic-Font", withExtension: "otf")!
let data = try! Data(contentsOf: url)
let provider = CGDataProvider(data: data as CFData)
print("Test 1")
let font = CGFont(provider!)
print("Test 2")
var error: Unmanaged<CFError>?
if !CTFontManagerRegisterGraphicsFont(font, &error) {
//Error handling here
} else {
log.info("Material Font registered");
}
}
Run Code Online (Sandbox Code Playgroud)
控制台仅打印测试1.
有人有什么想法吗?
NB:.这个应用程序在带有SIM卡的testPhone上运行,而不是在没有 SIM卡的手机上运行!
编辑:堆栈跟踪 如果我在调试控制台中按pauze,将显示以下堆栈跟踪:
libsystem_kernel.dylib`semaphore_wait_trap:
0x10c765fa4 <+0>: movq %rcx, %r10
0x10c765fa7 <+3>: movl $0x1000024, %eax …Run Code Online (Sandbox Code Playgroud) ios ×3
swift ×3
alamofire ×1
freeze ×1
hang ×1
http-headers ×1
request ×1
swift3 ×1
transition ×1