小编Kos*_*awa的帖子

MKAnnotationView图层不是预期类型:MKLayer

所以我的代码工作正常,但我的记录器充满了这个消息.有没有办法摆脱它或抑制它?

PostAnnotation.swift

class PostAnnotation: MKPointAnnotation {

    //MARK: properties
    let post: Post

    //MARK: initialization
    init(post: Post) {
        self.post = post
        super.init()
        self.coordinate = CLLocationCoordinate2D(latitude: post.latitude, longitude: post.longitude)
        self.title = post.title
        self.subtitle = post.timeString()
    }

}
Run Code Online (Sandbox Code Playgroud)

添加注释

let annotation = PostAnnotation(post: post)
self.map.addAnnotation(annotation)
Run Code Online (Sandbox Code Playgroud)

func mapView

func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {

    if annotation is MKUserLocation {
        return nil
    }

    var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "pin") as? MKPinAnnotationView
    if annotationView == nil {
        annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "pin")
    } …
Run Code Online (Sandbox Code Playgroud)

mapkit ios swift

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

用宏检测iPhone X.

如何检测iPhone X上的运行?我尝试了以下代码.

#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IS_IPHONE_X (IS_IPHONE && SCREEN_MAX_LENGTH == 812.0)
Run Code Online (Sandbox Code Playgroud)

当我在iOS模拟器中运行此宏时,IS_IPHONE_X则为真.这个宏是否正确?

cocoa-touch objective-c ios

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

iOS 11 中推送通知上的应用名称是否总是全大写?

我注意到通知上的标题是应用程序显示名称,强制全部大写。

客户的应用程序名称是大写和小写的混合,这是他们品牌的一部分。他们希望这个名字尊重混合的大写/小写。

有没有人知道更改通知中显示的文本的方法,或者我们是否坚持使用大写版本的应用程序显示名称?

通知

apple-push-notifications ios

6
推荐指数
0
解决办法
1198
查看次数

Javascript:无法在 Else 上读取 null 的属性“样式”

错误消息:Cannot read property 'style' of null 出现在我的“else”语句的第一条语句中。不知道我哪里出错了。有什么想法吗?

$(document).ready(function () {
    var foursquareApi = {
        clientId: "CLIENT_ID",
        clientSecret: "CLIENT_SECRET",
        redirectUrl: "http://almontas.github.io/FourSquareJax/"
    }

    if (access_token === 0) {

        document.getElementById('dashboardProfile').style.display == 'none';
        document.getElementById('dashboardInfo').style.display == 'none';

        $('.connect').click(function () {

            var url = "https://foursquare.com/oauth2/access_token";
            url += "?client_id=" + foursquareApi.clientId;
            url += "&response_type=token";
            url += "&redirect_uri=" + foursquareApi.redirectUrl;
            window.location = url;

        });
    } else {
        document.getElementById('dashboardProfile').style.display == 'block'; //this lines gives an error message. 
        document.getElementById('dashboardInfo').style.display == 'block';
    }
Run Code Online (Sandbox Code Playgroud)

这是一些有问题的 HTML。如评论所述, .dashboardProfile 和 .dashboardInfo 似乎已经到位。

<body>
        <div …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

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