RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-240533

Volodymyr Slipak's questions

Martin Hope
Volodymyr Slipak
Asked: 2020-09-19 02:27:11 +0000 UTC

控制器之间转换期间的内存丢失以及死应用程序(未运行)中的 Firebase 通知问题

  • 0

谁可以解释或在俄语中可以清楚地阅读有关如何在控制器之间正确切换的信息(没有 UINavigationViewController)

在应用程序中我使用将棋(例如推送和演示模式)

当推送带有其他数据(切换到 ActiveInfoVC)时与内存相同的图片,如果返回则内存不会下降

如果您多次重复所有内容,那么应用程序就会崩溃

如何正确进行转换以及如何在控制器关闭时从内存中杀死控制器(我知道在 andriod 中有一个方法 - Finish()) swift 中有什么相似之处?解雇并不总是有效

这是使用 AppDrlegate 捕获 PushNotification 的代码

并且由于某种原因,它仅在应用程序正在运行或在后台运行时才有效,当它被杀死时 - 什么也没有出现,尽管服务器写了 200 OK

这是用于 PushNotification 的 AppDrlegate 代码 整个故事板 记忆

当推送带有其他数据(切换到 ActiveInfoVC)时与内存相同的图片,如果返回则内存不会下降

func userNotificationCenter(_ center: UNUserNotificationCenter,
                            didReceive response: UNNotificationResponse,
                            withCompletionHandler completionHandler: @escaping () -> Void) {
    let userInfo = response.notification.request.content.userInfo
    // Print message ID.
    if let messageID = userInfo[gcmMessageIDKey] {
        print("Message ID: \(messageID)")
    }
    //по тапу з пуша

    // Print full message.
    print(userInfo)
    print("по тапу с пуша==================", userInfo["type"]!)


    if userInfo["type"]! as! String == "add_manager" {

        let storyboard = UIStoryboard(name: "SearchSB", bundle: nil)
        let vc = storyboard.instantiateViewController(withIdentifier: "FindOrderVC") as! FindOrderVC

        vc.name = userInfo["manager_name"]! as! String
        vc.phone = userInfo["manager_phone"]! as! String
        vc.photo = userInfo["manager_photo"]! as! String
        window?.rootViewController = vc
        completionHandler()

    } else if userInfo["type"]! as! String == "new_shipment_request" {

        let storyboard = UIStoryboard(name: "SearchSB", bundle: nil)
        let vc = storyboard.instantiateViewController(withIdentifier: "ActiveInfoVC") as! ActiveInfoVC
        vc.orderId = userInfo["id"]! as! String
        vc.contentType = userInfo["type"]! as! String
        window?.rootViewController = vc
        completionHandler()
    }
}


func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

    print(userInfo)
    print("1 РАЗ==================", userInfo["type"]!)

            switch application.applicationState {

            case .inactive:
                print("Inactive")
                //  NEVER CALL HERE

                //Show the view with the content of the push
                completionHandler(UIBackgroundFetchResult.newData)
                return

            case .background:
                print("Background")
                //Refresh the local model
                completionHandler(UIBackgroundFetchResult.newData)
                return

            case .active:
                print("Active")
                //Show an in-app banner
                completionHandler(UIBackgroundFetchResult.newData)
                return
            }
}
firebase
  • 1 个回答
  • 10 Views
Martin Hope
Volodymyr Slipak
Asked: 2020-09-11 19:39:39 +0000 UTC

如何在mapBox中为地图上的点创建一个集群?

  • 0

Mapbox SDK Swift 3 在地图上有一个带有点的数组,如何为数组中的点创建一个集群?我无法添加示例和文档,因为它们使用 JSON 计分

在这里我得到了一系列注释

/////[GET ANNOTATIONS]////////
func pin (_ str: String = "All") -> [MGLAnnotation] {

    self.places.removeAll()



    let context: NSManagedObjectContext = CoreDataManager.instance.managedObjectContext
    let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "DictPlace")

    if str != "All" {


        fetch.predicate = NSPredicate(format: "category == %@", str)
    }

    let sortDescriptor = NSSortDescriptor(key: "name", ascending: true)
    fetch.sortDescriptors = [sortDescriptor]

    fetch.returnsObjectsAsFaults = false

    let fetchResults = try! context.fetch(fetch)



    let ct = fetchResults.count


    for row in 0...ct-1 {
        let data: NSManagedObject = fetchResults[row] as! NSManagedObject


        let placeElement = data as! DictPlace

        places.append(placeElement)

    }

    for place in places {

        let location = place.loc
        let annotation = PlaceAnnotation()
        annotation.myPlace = place

        annotation.title = place.name
        annotation.subtitle = place.rating


        let latitude = NSString(string: (location.latitude)!).doubleValue
        let longitude = NSString(string: (location.longitude)!).doubleValue

        annotation.coordinate = CLLocationCoordinate2D(latitude: (latitude), longitude: (longitude))
        arrayPins.append(annotation)
    }

    return arrayPins
}


func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
     ВОТ ТУТ НЕ ЗНАЮ КАК ПОДСТАВИТЬ МОЙ МАСИВ С ТОЧКАМИ МЕСТО URL на файл JSON
    let url = URL(fileURLWithPath: Bundle.main.path(forResource: "ports", ofType: "geojson")!)

    let source = MGLShapeSource(identifier: "clusteredPorts",
                                url: url,
                                options: [.clustered: true, .clusterRadius: icon.size.width])
    style.addSource(source)


    // Use a template image so that we can tint it with the `iconColor` runtime styling property.
    style.setImage(icon.withRenderingMode(.alwaysTemplate), forName: "icon")

    // Show unclustered features as icons. The `cluster` attribute is built into clustering-enabled source features.
    let ports = MGLSymbolStyleLayer(identifier: "ports", source: source)
    ports.iconImageName = MGLStyleValue(rawValue: "icon")
    ports.iconColor = MGLStyleValue(rawValue: UIColor.darkGray.withAlphaComponent(0.9))
    ports.predicate = NSPredicate(format: "%K != YES", "cluster")
    style.addLayer(ports)

    // Color clustered features based on clustered point counts.
    let stops = [
        20:  MGLStyleValue(rawValue: UIColor.lightGray),
        50:  MGLStyleValue(rawValue: UIColor.orange),
        100: MGLStyleValue(rawValue: UIColor.red),
        200: MGLStyleValue(rawValue: UIColor.purple)
    ]

    // Show clustered features as circles. The `point_count` attribute is built into clustering-enabled source features.
    let circlesLayer = MGLCircleStyleLayer(identifier: "clusteredPorts", source: source)
    circlesLayer.circleRadius = MGLStyleValue(rawValue: NSNumber(value: Double(icon.size.width) / 2))
    circlesLayer.circleOpacity = MGLStyleValue(rawValue: 0.75)
    circlesLayer.circleStrokeColor = MGLStyleValue(rawValue: UIColor.white.withAlphaComponent(0.75))
    circlesLayer.circleStrokeWidth = MGLStyleValue(rawValue: 2)
    circlesLayer.circleColor = MGLSourceStyleFunction(interpolationMode: .interval,
                                                      stops: stops,
                                                      attributeName: "point_count",
                                                      options: nil)
    circlesLayer.predicate = NSPredicate(format: "%K == YES", "cluster")
    style.addLayer(circlesLayer)

    // Label cluster circles with a layer of text indicating feature count. Per text token convention, wrap the attribute in {}.
    let numbersLayer = MGLSymbolStyleLayer(identifier: "clusteredPortsNumbers", source: source)
    numbersLayer.textColor = MGLStyleValue(rawValue: UIColor.white)
    numbersLayer.textFontSize = MGLStyleValue(rawValue: NSNumber(value: Double(icon.size.width) / 2))
    numbersLayer.iconAllowsOverlap = MGLStyleValue(rawValue: true)
    numbersLayer.text = MGLStyleValue(rawValue: "{point_count}")
    numbersLayer.predicate = NSPredicate(format: "%K == YES", "cluster")
    style.addLayer(numbersLayer)

    // Add a tap gesture for zooming in to clusters or showing popups on individual features.
    view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTap(_:))))
}

func mapViewRegionIsChanging(_ mapView: MGLMapView) {
    showPopup(false, animated: false)
}

func handleTap(_ tap: UITapGestureRecognizer) {
    if tap.state == .ended {
        let point = tap.location(in: tap.view)
        let width = icon.size.width
        let rect = CGRect(x: point.x - width / 2, y: point.y - width / 2, width: width, height: width)

        let clusters = mapView.visibleFeatures(in: rect, styleLayerIdentifiers: ["clusteredPorts"])
        let ports = mapView.visibleFeatures(in: rect, styleLayerIdentifiers: ["ports"])

        if clusters.count > 0 {
            showPopup(false, animated: true)
            let cluster = clusters.first!
            mapView.setCenter(cluster.coordinate, zoomLevel: (mapView.zoomLevel + 1), animated: true)
        } else if ports.count > 0 {
            let port = ports.first!

            if popup == nil {
                popup = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 40))
                popup!.backgroundColor = UIColor.white.withAlphaComponent(0.9)
                popup!.layer.cornerRadius = 4
                popup!.layer.masksToBounds = true
                popup!.textAlignment = .center
                popup!.lineBreakMode = .byTruncatingTail
                popup!.font = UIFont.systemFont(ofSize: 16)
                popup!.textColor = UIColor.black
                popup!.alpha = 0
                view.addSubview(popup!)
            }

            popup!.text = (port.attribute(forKey: "name")! as! String)
            let size = (popup!.text! as NSString).size(attributes: [NSFontAttributeName: popup!.font])
            popup!.bounds = CGRect(x: 0, y: 0, width: size.width, height: size.height).insetBy(dx: -10, dy: -10)
            let point = mapView.convert(port.coordinate, toPointTo: mapView)
            popup!.center = CGPoint(x: point.x, y: point.y - 50)

            if popup!.alpha < 1 {
                showPopup(true, animated: true)
            }
        } else {
            showPopup(false, animated: true)
        }
    }
}

func showPopup(_ shouldShow: Bool, animated: Bool) {
    let alpha: CGFloat = (shouldShow ? 1 : 0)
    if animated {
        UIView.animate(withDuration: 0.25) { [unowned self] in
            self.popup?.alpha = alpha
        }
    } else {
        popup?.alpha = alpha
    }
}
xcode
  • 1 个回答
  • 10 Views
Martin Hope
Volodymyr Slipak
Asked: 2020-09-05 17:20:54 +0000 UTC

在 viewController 之间行走的正确方法是什么?

  • 0

如何正确地在它们之间行走,viewControllers以便每次都重新加载它们viewDidLoad,当它们离开控制器时,它会死掉并从内存中删除。在项目中,我使用了很多故事板之间的转场和过渡

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        if segue.identifier == "toDocDetail" {

        }
    }



let vc = UIStoryboard(name: "DetailOrderSB", bundle: nil).instantiateViewController(withIdentifier: "DetailOrderVC") as! DetailOrderVC
            vc.orderID = cell_data!.id
            vc.statusID = cell_data!.statusId
            self.present(vc, animated: true, completion: nil)

关闭时,我只使用沿当前行的过渡或self.dismiss(animated: true, completion: nil)

但是我遇到了一个问题,view在控制器之间的几次转换后,表和不同的表开始严重冻结, NavigationViewController我不使用它,只有ViewController

有人可以解释如何正确地走动所有这些而不丢失设备的逻辑和资源吗?也许有什么要读的?

ios
  • 1 个回答
  • 10 Views
Martin Hope
Volodymyr Slipak
Asked: 2020-04-03 20:10:55 +0000 UTC

每个用户的 Firebase 流量减少

  • 1

现在它是这样完成的:从Firebase 实时数据库 (FDB)读取数据并将其写入CoreData(CD)。有一个强制更新按钮(我完全清除了CD并通过FDB覆盖了数据observeSingleEvent)

加载清除数据并将数据写入CoreData的函数:

func loadCDDAta(completionHandler: @escaping CompletionHandler) {

    ref = FIRDatabase.database().reference()

    NetworkCheckingClass.isConnectedToNetwork(){

        isConnected in

        if isConnected == true {

            if Reachability.sharedInstance.isConnectedToNetwork() == true {

                self.ref.observeSingleEvent(of: .value, with: { (snapshot: FIRDataSnapshot) in


                    let value = snapshot.value as? NSDictionary


                    if snapshot.value != nil {

                        self.deleteRecords()

                        if let f = value?["Place"] as? [String:AnyObject] {

                            CoreDataManager.instance.saveCDDict(f)
                        } else if let f = value?["Place"] as? [AnyObject] {

                            CoreDataManager.instance.saveCDArray(f)

                        }

                        completionHandler(true)

                    } else {

                        completionHandler(false)

                    }

                }) { (error) in
                    completionHandler(false)
                    print(error.localizedDescription)
                }

            } else {

                completionHandler(false)
                print("NO Connect")

            }

            print("Connect OK")

        } else {

            completionHandler(false)
            print("NO Connect")
        }
    }

}



func deleteRecords() -> Void {
    let moc = CoreDataManager.instance.managedObjectContext
    let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "DictPlace")

    let result = try? moc.fetch(fetchRequest)
    let resultData = result as! [DictPlace]

    for object in resultData {
        moc.delete(object)

    }

    do {

        try moc.save()
        print("saved!")
    } catch let error as NSError  {
        print("Could not save \(error), \(error.userInfo)")
    } catch {

    }

}

也就是说,如果来自Firebase的 Json重量为 20Mb,那么它会提取所有 20Mb。

有必要:通过按下按钮,观察FDB中的数据变化,如果发生变化,则仅将已更改或新的数据添加到CD (不删除其他所有内容)。如果什么都没有改变——那就不要碰任何东西。

仅包含来自Firebase的更新数据的 Json最大重量为 100-200Kb + 更少的加载时间。

база-данных
  • 1 个回答
  • 10 Views
Martin Hope
Volodymyr Slipak
Asked: 2020-03-16 17:23:56 +0000 UTC

Firebase observeSingleEvent withCancel 100% 丢失网络模式在 cancelBlock 中不起作用

  • 0

从商店发送拒绝:

性能-2.1

此外,我们无法审查您的应用程序,因为它在启动时崩溃了。我们附有详细的崩溃日志,以帮助解决此问题。

下一步

  1. 请修改您的应用程序并在连接到 IPv6 网络的设备上对其进行测试(所有应用程序都必须支持 IPv6)以确保它可以启动而不会崩溃。由于您的 iTunes Connect 状态为 Rejected,因此需要一个新的二进制文件。
  2. 上传新的二进制文件时进行所需的元数据更改。

资源

有关如何符号化和读取崩溃日志的信息,请参阅技术说明 TN2151了解和分析应用程序崩溃报告。有关支持 IPv6 网络的更多信息,请参阅支持 IPv6 DNS64/NAT64 网络和支持 IPv6-only 网络。有关网络概述,请参阅关于网络。

问题是如果有一个不工作的互联网(网络 100% 丢失),程序无法从 firebase 接收数据,并且没有进入 CancelBlock 就会无休止地下载。我也想不出拐杖,因为我尝试了各种互联网检查(它们没有帮助)。

这是日志:

app_instance_id=C2F4F7BE218E4810A18090E113C9B7FF&platform=ios&gmp_version=3600,
_kCFStreamErrorCodeKey=-2103, NSErrorFailingURLKey=https://app-measurement.com/config/app/1:714764542827..,
NSLocalizedDescription=The request timed out.,
_kCFStreamErrorDomainKey=4}

这是问题所在的功能:

typealias CompletionHandler = (_ success:Bool) -> Void

func loadCDDAta(completionHandler: @escaping CompletionHandler) {

    ref = FIRDatabase.database().reference()

    ref.observeSingleEvent(of: .value, with: { (snapshot: FIRDataSnapshot) in

        if snapshot.exists() && snapshot.value != nil {
            let value = snapshot.value as? NSDictionary
            self.deleteRecords()
            if let f = value?["Place"] as? [String:AnyObject] {
                CoreDataManager.instance.saveCDDict(f)
            }
            else if let f = value?["Place"] as? [AnyObject] {
                CoreDataManager.instance.saveCDArray(f)
            }
            completionHandler(true)
                print("completionHandler(true)")

        } else {
            completionHandler(false)
                print("completionHandler(false)")

    }

}, withCancel: { (error: Error) in

    completionHandler(false)
        print("completionHandler(false)")

})
}

代码截图

xcode
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5