Posts

Post marked as solved
4 Replies
2.7k Views
my problem occurs when you press the button on the sidebar of the web view. The button sends a simple message to the web view and copies the clipboard. And Swift shows you the received message as a toast. It's very simple.The function does not appear to be problematic,but the UI is a problem. When the button is pressed, the screen slides from top to bottom, showing the toast and pressing the button again activates the function of pressing the other button on the sidebar.The screen is the same, but the screen seems to be down. The sidebar screen contains a scroll. Is that what it is about?Error log: Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) ( "", "", "", "", "=8)-| (active, names: '|':_UIButtonBarButton:0x133dcc1d0 )>", "=5)-[_UIModernBarButton:0x133ecbe60] (active, names: '|':_UIButtonBarButton:0x133ecbc10 )>", "=5)-| (active, names: '|':_UIButtonBarButton:0x133ecbc10 )>", "", "", "<nslayoutconstraint:0x283a85ae0 'uisv-canvas-connection'="" uilayoutguide:0x2820c1c00'uiviewlayoutmarginsguide'.leading="=" _uibuttonbarbutton:0x133dcc1d0.leading ="" (active)="">", "<nslayoutconstraint:0x283a85cc0 'uisv-canvas-connection'="" uilayoutguide:0x2820c1c00'uiviewlayoutmarginsguide'.trailing="=" _uibuttonbarbutton:0x133ecc380.trailing ="" (active)="">", "<nslayoutconstraint:0x283a85d10 'uisv-spacing'="" h:[_uibuttonbarbutton:0x133dcc1d0]-(0)-[uiview:0x133e94d90] ="" (active)="">", "<nslayoutconstraint:0x283a85d60 'uisv-spacing'="" h:[uiview:0x133e94d90]-(0)-[_uibuttonbarbutton:0x133ecbc10] ="" (active)="">", "<nslayoutconstraint:0x283a85db0 'uisv-spacing'="" h:[_uibuttonbarbutton:0x133ecbc10]-(0)-[uiview:0x133ecc1a0] ="" (active)="">", "<nslayoutconstraint:0x283a85e00 'uisv-spacing'="" h:[uiview:0x133ecc1a0]-(0)-[_uibuttonbarbutton:0x133ecc380] ="" (active)="">", "<nslayoutconstraint:0x283a835c0 'uiview-encapsulated-layout-width'="" uitoolbar:0x133ebef70.width="=" 0 ="" (active)="">", "<nslayoutconstraint:0x283a8b250 'uiview-leftmargin-guide-constraint'="" h:|-(0)-[uilayoutguide:0x2820c1c00'uiviewlayoutmarginsguide'](ltr) ="" (active,="" names:="" '|':_uibuttonbarstackview:0x133ec0570="" )="">", "<nslayoutconstraint:0x283a8b2f0 'uiview-rightmargin-guide-constraint'="" h:[uilayoutguide:0x2820c1c00'uiviewlayoutmarginsguide']-(0)-|(ltr) ="" (active,="" names:="" '|':_uibuttonbarstackview:0x133ec0570="" )="">" ) Will attempt to recover by breaking constraint =8)-| (active, names: '|':_UIButtonBarButton:0x133dcc1d0 )> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.Found the cause of the problem. Pressing the button will bring up the keyboard and disappear again. Why is this happening?The function of this button communicates with me. Button asks me to show him a toast message.JSfunction~~~jsfunction copy_address(){ var t = document.createElement("textarea"); document.body.appendChild(t); t.value = $("#text").val(); t.select(); document.execCommand('copy'); document.body.removeChild(t); var postData = { tip: "testing", message: "sucess", timestamp: (new Date()).getTime().toString() }; webkit.messageHandlers.send.postMessage(postData); }~~~JSP Button View~~~jsp<div class="w" id="user"></div><div class="b-copy"><button type="button" class="btn" onclick="copy_address()">copy</button><input type="text" id="copy_text" style="display: none;"></div>~~~**Swift Code in WebViewController**~~~swiftimport Toaster ... override func loadView() { super.loadView() ... mainWebView = WKWebView(frame: mainWebView.frame, configuration: config) mainWebView.uiDelegate = self mainWebView.navigationDelegate = self view.addSubview(mainWebView) view.addSubview(indicatorImage) } @available(iOS 8.0, *) func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { if message.name == "message" { let sendmessage = message.body as! NSDictionary guard sendmessage["val"] != nil else { return } let val : String = sendmessage["val"] as! String if sendmessage["val2"] != nil { getmessage = sendmessage["val2"] as? String } switch val { case "testing": Toast(text: getmessage).show() break .... } }~~~
Posted Last updated
.
Post marked as solved
5 Replies
2.5k Views
the problem I have is to remove the root arrow on the story board and set up the root view in the **AppDelegate** file to dynamically change the RootView.There is no problem moving the root view, but the existing `splashScreen(Launch Screen)` is not visible. Why can't you see it? How can I see the `splashScreen(Launch Screen)` and go to the root view?**Main.Storyboard**https://ifh.cc/g/0LXBV.png**Login.Storyboard,**https://ifh.cc/g/CtlFX.png**Launch.Storyboard**https://ifh.cc/g/pps62.png**Move Root Screen in AppDelegate.swift**~~~swiftvar window: UIWindow? func switchStartUI() { let mainStoryboard = UIStoryboard(name: "Main", bundle: nil) let viewController = mainStoryboard.instantiateViewController(withIdentifier: "StartViewController") self.window?.rootViewController = viewController } func switchToMainUI() { let mainStoryboard = UIStoryboard(name: "Main", bundle: nil) let viewController = mainStoryboard.instantiateViewController(withIdentifier: "NavigationController") self.window?.rootViewController = viewController } func switchLoginUI(_ pushtype : String) { let loginStoryboard = UIStoryboard(name: "Login", bundle: nil) let viewController = loginStoryboard.instantiateViewController(withIdentifier: "MainLoginController") as! MainLoginController viewController.pushType = pushtype self.window?.rootViewController = viewController } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { self.window = UIWindow(frame: UIScreen.main.bounds) if let screenData : String = LocalStorage.get("ScreenView") as? String { switch (screenData) { case "success": switchToMainUI() case "success1": switchLoginUI("") case "success2": switchLoginUI("") default: switchStartUI() } } else { switchStartUI() } self.window?.makeKeyAndVisible() return true }~~~I want to see the splash screen and move on to the root viewThere is already an image on my splash screen. It worked normally. But I can't see the splash screen after dynamically modifying the root view. I'm the samehelp me a lot
Posted Last updated
.
Post marked as solved
1 Replies
11k Views
I am developing message communication through FCM.But there's a problem. On `iPhone 6`, version `12.4`, you can normally get device tokens and FCM values.However, `11.4` does not get a device token value, nor does it get an FCM token value. I don't know what the problem is.AppDelegate.swift~~~swiftimport UIKit import UserNotifications import Firebase import FirebaseMessaging @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate { func registerAppForPushNotificaition(){ if #available(iOS 10.0, *) { let center = UNUserNotificationCenter.current() let inviteCategory = UNNotificationCategory(identifier: "Notification", actions: [], intentIdentifiers: [], options: UNNotificationCategoryOptions.customDismissAction) let categories = NSSet(objects: inviteCategory) center.delegate = self center.setNotificationCategories(categories as! Set) center.requestAuthorization(options: [.sound, .badge, .alert], completionHandler: { (granted, error) in if !(error != nil){ DispatchQueue.main.async(execute: { UIApplication.shared.registerForRemoteNotifications() }) } }) } else { UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types:[.sound , .alert , .badge] , categories: nil)) UIApplication.shared.registerForRemoteNotifications() } } @available(iOS 10.0, *) func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { completionHandler(.alert) } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { self.window = UIWindow(frame: UIScreen.main.bounds) // Override point for customization after application launch. //create the notificationCenter Messaging.messaging().delegate = self FirebaseApp.configure() //Register App For Push Notification let center = UNUserNotificationCenter.current() let inviteCategory = UNNotificationCategory(identifier: "Notification", actions: [], intentIdentifiers: [], options: UNNotificationCategoryOptions.customDismissAction) let categories = NSSet(objects: inviteCategory) center.delegate = self center.setNotificationCategories(categories as! Set) DispatchQueue.main.async(execute: { UIApplication.shared.registerForRemoteNotifications() }) application.registerForRemoteNotifications() } func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { let token = deviceToken.map{ String(format: "%02x", $0) }.joined() Log.Info("Registration succeeded!") Log.Info("Token: \(token)") Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.sandbox) Messaging.messaging().apnsToken = deviceToken InstanceID.instanceID().instanceID { (result, error) in if let error = error { Log.Error("Error fetching remote instance ID: \(error)") } else if let result = result { Log.Info("Remote instance ID token: \(result.token)") LocalStorage.set(result.token, "dacDeviceToken") } } Messaging.messaging().shouldEstablishDirectChannel = true } func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) { Messaging.messaging().apnsToken = deviceToken as Data // print(deviceToken) } func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { Log.Warning("Registration failed!") } func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { if Auth.auth().canHandleNotification(userInfo) { Log.Info("fetchCompletionHandler") completionHandler(UIBackgroundFetchResult.noData) return } Log.Info("fetchCompletionHandler") completionHandler(UIBackgroundFetchResult.newData) } func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String) { Log.Info("fcmToken \(fcmToken)") } func messaging(_ messaging: Messaging, didReceive remoteMessage: MessagingRemoteMessage) { Log.Info("remort \(remoteMessage.appData)") } func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. Log.Info("applicationWillResignActive") } func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. Log.Info("applicationDidEnterBackground") } func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. Log.Info("applicationWillEnterForeground") } func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. Log.Info("applicationDidBecomeActive") } func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. Log.Info("applicationWillTerminate") } func getNotificationSettings() { UNUserNotificationCenter.current().getNotificationSettings { settings in print("Notification settings: \(settings)") guard settings.authorizationStatus == .authorized else { return } DispatchQueue.main.async { UIApplication.shared.registerForRemoteNotifications() } } } @available(iOS 10, *) func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { let data = response.notification.request.content.userInfo Log.Info(data) guard let aps = data[AnyHashable("aps")] as? NSDictionary, let alert = aps["alert"] as? NSDictionary, let body = alert["body"] as? String else { Log.Error("it's not good data") return } completionHandler() }~~~**On iPhone 12.4, FCM token values are received here. And the iOS version is the same.**~~~swiftfunc application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { let token = deviceToken.map{ String(format: "%02x", $0) }.joined() Log.Info("Registration succeeded!") Log.Info("Token: \(token)") Auth.auth().setAPNSToken(deviceToken, type: AuthAPNSTokenType.sandbox) Messaging.messaging().apnsToken = deviceToken InstanceID.instanceID().instanceID { (result, error) in if let error = error { Log.Error("Error fetching remote instance ID: \(error)") } else if let result = result { Log.Info("Remote instance ID token: \(result.token)") LocalStorage.set(result.token, "dacDeviceToken") } } Messaging.messaging().shouldEstablishDirectChannel = true }~~~Podfile # Pods for DeleteMe pod 'SwiftSVG', '~> 2.0' pod 'Toaster' pod 'BigInt', '~> 4.0' pod 'CryptoSwift' pod 'RealmSwift' pod 'web3.swift.pod', '~> 2.2.0' pod 'Firebase' pod 'Firebase/Messaging' pod 'Firebase/Auth'11.4 in Iphone Log~~~2019-10-02 13:39:01.964008+0900 test[1804:476574] - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist2019-10-02 13:39:02.045557+0900 test[1804:476574] 6.9.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more:2019-10-02 13:39:02.099986+0900 test[1804:476574] 6.9.0 - [Firebase/Analytics][I-ACS023007] Analytics v.60102000 started2019-10-02 13:39:02.102201+0900 test[1804:476574] 6.9.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled2019-10-02 13:39:02.139092+0900 test[1804:476582] 6.9.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:to ensure proper integration.2019-10-02 13:39:02.231208+0900 test[1804:476536] [Graphics] UIColor created with component values far outside the expected range. Set a breakpoint on UIColorBreakForOutOfRangeColorComponents to debug. This message will only be logged once.INFO: 2019-10-02 04:39:02 +0000 - <UI> AppDelegate.swift applicationDidBecomeActive(_:) [Line:225]applicationDidBecomeActive2019-10-02 13:39:02.371104+0900 test[1804:476581] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles2019-10-02 13:39:02.373237+0900 test[1804:476581] [MC] Reading from public effective user settings.~~~However, you can't see logs of FCM Token or device token values anywhere on iPhone 11.4. How can you solve this problem?
Posted Last updated
.
Post not yet marked as solved
0 Replies
345 Views
I am currently working on the project with `iOS`.So far, there have been no problems with the UI, but this updated version of `iOS 13` has become a problem. As the `iOS` version is updated to 13, the previous screen will be shown in the top line as the stack builds up as I go to the screen. I'd like to get rid of this, but I don't know how to get rid of it.**ViewController in Storyboard**https://ifh.cc/g/vkHvH.png
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
I am currently working on the `ios` project with `swift`. My problem is that I cannot call the function of the `webview` page.I followed the guide but it didn't work. My `webview` page is `Spring-MVC` structure.**js function in Spingproject**~~~jsfunction set_localstorage(data){alert(data)console.log("##################################################")var event = JSON.parse(data);localStorage.setItem('name', event.name);}~~~**call function in ios**~~~swift@IBOutlet var mainWebView: WKWebView!var contentController = WKUserContentController()... override func loadView() { super.loadView() let config = WKWebViewConfiguration() let userScript = WKUserScript(source: "this.set_localstorage(haha)", injectionTime: .atDocumentEnd, forMainFrameOnly: true) contentController.addUserScript(userScript) config.userContentController = contentController mainWebView = WKWebView(frame: mainWebView.frame, configuration: config) mainWebView.uiDelegate = self mainWebView.navigationDelegate = self view.addSubview(mainWebView) view.addSubview(indicatorImage) }... override func viewDidLoad() { super.viewDidLoad() let mainUrl = globalUrl.getMainURL() guard let myUrl = URL(string: mainUrl) else { //report invalid URL return } let myRequest = URLRequest(url: myUrl) mainWebView.navigationDelegate = self mainWebView.load(myRequest) }~~~What's the problem? What am I missing?I can's see alertThis is a function that I go to the webview screen.~~~swift func moveScreen() { let storyboard = UIStoryboard(name: "Main", bundle: nil) let moveScreen = storyboard.instantiateViewController(withIdentifier: "mainWebViewController") as! mainWebViewController moveScreen.modalPresentationStyle = .overCurrentContext moveScreen.modalTransitionStyle = .crossDissolve self.present(moveScreen, animated: false, completion: nil) }~~~
Posted Last updated
.