Tricking an iOS App in a Webview to simulate page reload detection

Hey there,

I'm currently dealing with an issue in my iOS app where I have a webview that monitors URL changes and displays a spinner while the page is loading. The problem arises when the webview now has hash changes to support back buttons, which prevents the spinner from disappearing because a hash change doesn't trigger a page reload event.

I'm wondering if there's a way using JavaScript within the webview to manipulate the document.readyState or any other method to trick the app into thinking the page has reloaded so that it removes the spinner.

Answer №1

One important delegate method for the UIWebView is:

  • (void)webViewDidFinishLoad:(UIWebView *)webView;

This method will be called when the URL finishes loading.

Answer №2

We experimented with different methods;

  1. Initially, we inserted an image (1x1 gif) into the page, but this did not successfully trigger a page load event...

  2. However, we then discovered that inserting an iframe into the page, and loading an empty html file within it, triggered the page load event once again and removed the native loading overlay.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing Cordova for Android and iOS platforms to enable Facebook login functionality

Implementing Facebook login functionality in a Cordova mobile app for both android and ios platforms. Through the use of Facebook's API, I am looking to retrieve the user profile data as well as fetch the friends associated with the logged-in Facebook ...

Produce a variety of shapes using Three.js

I am looking to generate multiple objects. var distance = 10; var geometry = new THREE.BoxGeometry(10,10,10); var material = new THREE.MeshBasicMaterial({color:0x00ff44}); for(var i = 0; i < 4;i++){ var mesh = new THREE.Mesh(g ...

A deep dive into the coordination between AngularJS factories and controllers

Can someone please explain the code snippet below to me? I found it on this website: http://www.html5rocks.com/en/tutorials/frameworks/angular-websockets Snippet from Factory: app.factory('socket', function ($rootScope) { var socket = io.co ...

execute an AJAX function when the TD element is not empty and is clicked

I currently have a table with an image inside the td. I am using an ajax function to update a value in the database when the td image is clicked. My issue is that if the td is empty (i.e., no image in the td), the same function still performs. What I want ...

Preventing Sorting in NSMutableDictionary

Currently, I am working with a NSMutableDictionary and it appears that the keys are being sorted automatically based on their first alphabet. Is there a way to prevent this automatic sorting from happening? I have tried changing the order of the keys but t ...

What is the process for calculating the product of a 4x4 Matrix with a vector-array of any size?

When creating a specific scene in webgl, the usual process of transforming an object involves defining the initial vertex position data and sending it to the vertex shader. In the shader, the vertices are manipulated by various matrices that contain inform ...

In the world of React Redux, there is a peculiar issue where the "return" statement fails to function within a particular Redux Action function, specifically

Attempting to make updates to a customer's name using React-Redux can be a bit tricky. Below is the component code: import React, { useEffect, useState } from "react"; import { Link, Navigate, useParams } from 'react-router-dom'; i ...

What is the best method to retrieve the id of a div when a button inside it is clicked?

I have a variety of panels, each with an "Add" button: <div id="panel1"> <input type="button" id="addbut" value="Add it"></input> </div> <div id="panel2"> <input type="button" id="addbut" value="Add it"></input> & ...

Use javascript to modify a specific section of a link

I have a set of datatable rows with links that contain data, and I need to modify part of the link text. For instance, if the link is 200.0.0.10, I want to change it to 160.11.10.12. Despite attempting the following code, the link does not change: var ...

If the function window.location.href.indexOf is malfunctioning

In order to display a specific element only when the location is correct, it should not appear otherwise. The following code is not functioning as expected: <div *ngIf="!accessTrue() && window.location.href.indexOf('something') > ...

Encountered a null value while converting a string to a date, formatting it, and then converting it back to

I have a specific date format: Sun, 07 Feb 2016 21:16:21 +0000 My requirement is to convert it into: dd.MM.yyyy The issue arises when using the following method, resulting in a fatal error with nil if parsedElement == "date" { if currentArticle.date ...

Background Services in the Moment

Currently in the process of developing a mobile application with the Ionic framework that utilizes Laravel 4 REST API for CRUD operations on a MySQL database. As per the requirements of the app, it needs to constantly communicate with the backend service t ...

Learn how to deactivate the pause button with just one click and re-enable it once the popup appears using Angular2 and Typescript

Can anyone assist with solving an issue I am facing with a timer and a pause button? I need the pause button to be disabled once clicked, until a popup appears, then it should become enabled again. My code snippet is provided below: HTML: <button md-i ...

How do you distinguish a change in date when launching iOS?

Looking for a way to update labels in a view based on the current day without storing the date information in core data. Is there a suitable persistent storage method that can help me identify if the date has changed since the last launch? Thanks! ...

Filter out specific fields from an object when populating in MongoDB using the aggregate method

Is there a way to use the populate() function in MongoDB to exclude specific fields like email and address, and only retrieve the name? For example: const results = await Seller.aggregate(aggregatePipeline).exec(); const sellers = await Seller.populate(re ...

New string not receiving updated global variable

I am experiencing an issue where I am attempting to assign a value to a global variable inside a function and then use that globally declared string with concatenation in another part of the code. Upon inspection within the method, it appears that the var ...

Navigation for GitHub pages

I've been working on this for what feels like forever. The persistent Error 404 I'm encountering is with the /Quest/questlist.txt file. https://i.sstatic.net/NYYRa.png Here's the code snippet I've been using: ``// QuestCarousel.tsx ...

Leveraging personalized criteria with smart-table

Is there a way to implement a custom search condition in a smart table? Typically, we define the search for a column like this: <input st-search="description" placeholder="Description..." type="search"/> However, I'm looking to use a custom f ...

Select items from object based on a specified array of IDs

I am facing a challenge with my list of objects that each have an array associated with them. For instance, take a look at this example: "-KpvPH2_SDssxZ573OvM" : { "date" : "2017-07-25T20:21:13.572Z", "description" : "Test", "id" : [ { ...

Avoiding the default action and using a false return value do not produce the

Despite trying preventDefault, return false, and stopImmediatePropagation, the page continues to redirect back to the first selection instead of redirecting to the textarea after inputting all required fields and clicking on the button. The issue persists ...