相关疑难解决方法(0)

如何查看iOS版本?

我想检查iOS设备的版本是否大于3.1.3 我尝试过的东西:

[[UIDevice currentDevice].systemVersion floatValue]
Run Code Online (Sandbox Code Playgroud)

但它不起作用,我只想要一个:

if (version > 3.1.3) { }
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

objective-c ios

837
推荐指数
13
解决办法
44万
查看次数

如果用户已启用推送通知,请在iPhone上确定

我正在寻找一种方法来确定用户是否通过设置启用或禁用了我的应用程序的推送通知.

iphone notifications push apple-push-notifications ios

206
推荐指数
11
解决办法
12万
查看次数

检查iOS位置服务

我有一个带有地图和按钮的视图(比如地图应用程序一次),允许用户在地图上居中和缩放他当前的位置.如果我不能使用locationServicesEnabled方法(总是返回YES),我应该创建一个BOOL属性来检查是否调用了didFailWithError方法并知道我是否可以调用button方法?

谢谢阅读.

编辑:

此代码对我不起作用.我正在使用模拟器.在询问locationServicesEnabled时,我总是得到YES.

// Gets the user present location.
- (IBAction)locateUser:(id)sender {

    if([CLLocationManager locationServicesEnabled]) {

        CLLocationCoordinate2D coordinate;

        coordinate.latitude = self.mapView.userLocation.location.coordinate.latitude;
        coordinate.longitude = self.mapView.userLocation.location.coordinate.longitude;

        [self zoomCoordinate:coordinate];
    } else {
        [[[[UIAlertView alloc] initWithTitle:@"Warning." message:@"Location services are disabled." 
                                    delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show];     
    }
}
Run Code Online (Sandbox Code Playgroud)

objective-c cllocationmanager ios

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