相关疑难解决方法(0)

UIAlertView/UIAlertController兼容iOS 7和iOS 8

我正在使用Swift编写应用程序,我需要显示警报.该应用必须兼容iOS 7和iOS 8.由于UIAlertView已被替换UIAlertController,如何在UIAlertController不检查系统版本的情况下检查是否可用?我听说Apple建议我们不要检查设备的系统版本,以确定API的可用性.

这就是我在iOS 8中使用的,但是在iOS 7上用" dyld: Symbol not found: _OBJC_CLASS_$_UIAlertAction" 崩溃了:

let alert = UIAlertController(title: "Error", message: message, preferredStyle: .Alert)
let cancelAction = UIAlertAction(title: "OK", style: .Cancel, handler: nil)
alert.addAction(cancelAction)
presentViewController(alert, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

如果我使用UIAlertView for iOS 8,我收到此警告: Warning: Attempt to dismiss from view controller <_UIAlertShimPresentingViewController: 0x7bf72d60> while a presentation or dismiss is in progress!

uialertview ios swift uialertcontroller

57
推荐指数
5
解决办法
5万
查看次数

dyld:找不到符号:_NSURLAuthenticationMethodClientCertificate尝试运行iOS应用程序时

我的应用程序崩溃了消息:

dyld:未找到符号:_NSURLAuthenticationMethodClientCertificate
参考自:/ var/mobile/Applications/C7B596AD-FB09-4685-BDFC-7E955A5DD185/IRON TRAINERS.app/IRON TRAINERS预期在:/System/Library/Frameworks/CFNetwork.framework/CFNetwork in/var/mobile/Applications/C7B596AD-FB09-4685-BDFC-7E955A5DD185/IRON TRAINERS.app/IRON TRAINERS(lldb)

当我尝试构建和运行时.当我从我的项目中删除CFNetwork时,它可以工作,我不知道为什么.

我刚刚安装了Xcode6Beta并打开了我的项目.它在Xcode5.1上运行良好.

更新:

它在使用Xcode 6的iOS模拟器上运行正常,问题出在运行iOS 7.1.1的设备上.

更新2:

下面选择的答案对我有用,虽然我已经将基础框架显式添加到我的项目中,但我必须将其删除并再次添加.至少现在问题已经解决了.:)

xcode frameworks objective-c cfnetwork ios

48
推荐指数
5
解决办法
4万
查看次数

在swift中显示UIAlertView时出错

我试图在我的快速应用程序中显示UIAlertView

    alert = UIAlertView(title: "",
        message: "bla",
        delegate: self,
        cancelButtonTitle: "OK")
    alert!.show()
Run Code Online (Sandbox Code Playgroud)

=> BAD_ACESS错误: - [_ UIAlertViewAlertControllerShim initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:]()

所以我怀疑自己.我把它设置为零

    alert = UIAlertView(title: "",
        message: "bla",
        delegate: nil,
        cancelButtonTitle: "OK")
    alert!.show()
Run Code Online (Sandbox Code Playgroud)

=> ARM_DA_ALIGN错误: - [_ UIAlertViewAlertControllerShim initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:]()


完整的代码

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UIAlertViewDelegate {

    @lazy var window = UIWindow(frame: UIScreen.mainScreen().bounds)
    @lazy var locationManager = CLLocationManager()
    var alert: UIAlertView? = nil

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
        //setup dummy window
        self.window.backgroundColor = UIColor.whiteColor()
        self.window.rootViewController = UIViewController() …
Run Code Online (Sandbox Code Playgroud)

uialertview swift uialertcontroller

9
推荐指数
2
解决办法
1万
查看次数

UIAlertView在Swift中不起作用

当我在swift中使用此代码时,我不知道为什么应用程序通过在"alertView.show()"部分中显示断点来终止,有人请帮助我.

var alertView = UIAlertView(
    title: "Hey",
    message: "Hello",
    delegate: self,
    cancelButtonTitle: "Cancel"
)
alertView.show()
Run Code Online (Sandbox Code Playgroud)

uialertview ios swift

3
推荐指数
1
解决办法
1万
查看次数