我似乎在让tvOS提示用户进行位置数据授权方面遇到了一些麻烦.我从iOS中复制并粘贴了工作代码,似乎没有提示用户.我使用下面列出的代码以及带字符串值的NSLocationWhenInUseUsageDescription键.我看到api的唯一区别是在iOS上它使用了startupdatinglocation()而在tvOS上它使用了requestLocation()(类似于watchOS)我已经逐步解决了问题,它实际上是在命令中请求USUseAuthorization()但是根本没有提示用户.
知道发生了什么事吗?
import UIKit
import CoreLocation
class ViewController: UIViewController {
var locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
if CLLocationManager.locationServicesEnabled(){
if CLLocationManager.authorizationStatus() == CLAuthorizationStatus.NotDetermined{
locationManager.requestWhenInUseAuthorization()
}
else if CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedWhenInUse{
locationManager.requestLocation()
}
}
}
Run Code Online (Sandbox Code Playgroud) 我是C++的新手并且到处研究过这个并且似乎无法弄清楚如何编译它并且不知道为什么.它适用于Visual C++,但不适用于Xcode.错误似乎在输入流上.有什么建议?
错误读取 - "未定义模板的隐式实例化'std :: _ basic_ifstream>'
#include <iostream>
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "The file is providing the data.";
ifstream myFile("/Users/me/Desktop/somewords.txt"); // * error
int i;
string s;
double d;
myFile >> i >> s >> d;
cout << "here is your data " << endl;
cout << i << endl << s << endl << d << endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)