小编And*_*rew的帖子

从UIAlertController访问输入

我有一个UIAlertController,当他们在TouchID屏幕上选择"输入密码"时会提示用户.如何在屏幕上显示后恢复用户的输入?

let passwordPrompt = UIAlertController(title: "Enter Password", message: "You have selected to enter your passwod.", preferredStyle: UIAlertControllerStyle.Alert)
passwordPrompt.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: nil))
passwordPrompt.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))

passwordPrompt.addTextFieldWithConfigurationHandler({(textField: UITextField!) in
                        textField.placeholder = "Password"
                        textField.secureTextEntry = true
                        })

presentViewController(passwordPrompt, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)

我知道OK按钮可能应该有一个处理程序,但是现在这段代码并没有真正做任何事情,但我想通过println显示文本字段的输出.这对我来说真的只是一个测试应用程序,可以学习Swift和一些新的API.

swift ios8 uialertcontroller

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

Xcode错误启动远程程序

我已经在堆栈溢出的地方看到了这一点,但是其他人的解决方案对我来说都不起作用.救命!请!

我正试图在我的iPhone上测试我的应用程序,它运行得非常好,直到我更新了Xcode和iOS(虽然我也在v4上).我无法让它同步应用程序.我试过转储这个文件/文件夹,转储缓存,退出重新启动Xcode,重新启动计算机,重新启动手机,我能想到的一切无济于事.有任何想法吗?

Error launching remote program: No such file or directory
(/Users/andrew/Library/Developer/Xcode/DerivedData/BTC_Exchange-drzeigaqfnjtatglpppiwxmscsoj/Build/Products/Debug-iphoneos/BTC Exchange.app/BTC Exchange).
Run Code Online (Sandbox Code Playgroud)

并且该文件确实存在,我可以告诉我没有权限问题,我也运行了整个磁盘权限检查.

iphone xcode cocoa-touch

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

未提示在应用程序中启用位置服务

更新:这不是一个重复.我已经在info.plist中添加了所需的密钥,如我原始问题中所述,问题仍然存在.我已经尝试了各种组合的所有三个键.

在任何人感到不安之前,我已阅读了许多Apple Dev论坛帖子和堆栈溢出帖子,无法弄清楚为什么我的应用程序拒绝提示用户允许使用时授权.

我已将以下密钥添加到我的Info.plist文件中,并附带一个String值:

NSLocationWhenInUseUsageDescription
Run Code Online (Sandbox Code Playgroud)

然后我写了(在Swift和Obj-C中)应该提示用户的代码:

@property CLLocationManager *location;
...
@synthesize location;
...
location = [[CLLocationManager alloc] init];
location.delegate = self;

location.desiredAccuracy = kCLLocationAccuracyBest;
location.distanceFilter = kCLDistanceFilterNone;

[location requestWhenInUseAuthorization];
[location startUpdatingLocation];


I'm using the following CLLocationManagerDelegate methods.
- (void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
- (void) locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
Run Code Online (Sandbox Code Playgroud)

这基本上是直接从Apple"LocateMe"示例代码中复制的.

无论我尝试什么样的各种序列或细微的变化,应用程序都不会提示允许授权.我已经使用switch语句来确定状态[CLLocationManager authorizationStatus],但不断收到"未确定"的响应.

if ([CLLocationManager locationServicesEnabled]) {
        switch ([CLLocationManager authorizationStatus]) {
            case kCLAuthorizationStatusAuthorizedAlways:
                NSLog(@"Always Authorized");
                break;
            case kCLAuthorizationStatusDenied:
                NSLog(@"Denied");
                break;
            case kCLAuthorizationStatusAuthorizedWhenInUse:
                NSLog(@"Authorized in Use");
                break;
            case …
Run Code Online (Sandbox Code Playgroud)

objective-c cllocationmanager cllocation ios

7
推荐指数
1
解决办法
6914
查看次数

Swift中的AuthorizationCreate(Xcode 6)

我一直在寻找一些帮助,为我的应用程序创建授权,让它以root身份运行一些shell脚本.我查看了Apple文档(当然用OBJ-C编写并且非常含糊),我正在尝试使用Swift中的代码示例.

我正在运行该AuthorizationCreate函数的错误:

    var authRef: AuthorizationRef
    let osStatus = AuthorizationCreate(nil, nil, kAuthorizationFlagDefaults, &authRef)
Run Code Online (Sandbox Code Playgroud)

'Int' is not convertible to 'AuthorizationFlags'

我只是想跟随以下文档中的代码片段:https://developer.apple.com/library/mac/documentation/Security/Conceptual/authorization_concepts/03authtasks/authtasks.html#//apple_ref/doc/UID/TP30000995-CH206-TP9

kAuthorizationFlagDefaults从这里找到了常数:https://developer.apple.com/library/mac/documentation/Security/Reference/authorization_ref/#//apple_ref/doc/constant_group/Authorization_Options

如果重要的话,我在10.10.1中跑步.

我已经看到了使用AppleScript的解决方案,但我真的想避免这种情况.

macos authorization swift xcode6

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