I have a number of web views in my app in which I need to be careful about allowing further HTML links.
I disallow links in the delegate method shouldStartLoadWithRequest. This works fine, except for one thing. In the web view, the links are still highlighted in blue. So the user naturally thinks they are active links, but when selected, I disallow the link from the delegate method. This leads to confusion for the user.
Is there a way for me to disable the link color, so text does not show as blue when it contains a link within a UIWebView?
Try injecting Javascript into the UIWebView to change the appearance of the links.
Removing the href from all anchors should clear the formatting.
Here's some Javascript to get you started if you need it:
for(a in document.getElementsByTagName("a")) { a.href= ""; }
This will do it:
self.webView.dataDetectorTypes = UIDataDetectorTypeNone;
For swift 3:
Try removing the types you don't want to show as link from webView.dataDetectorTypes
webView.dataDetectorTypes.remove(UIDataDetectorTypes.all)
Related
Our product is used by many corporate and government bodies.
Many of them are only allowed use IE and have security policies applied to their IE which they are not allowed adjust.
One such setting is the disabling of downloading web fonts.
We have work around in place to check if the font can be downloaded.
If not, we replace all <i> on the page with <img>.
var haveFont = detectFontIcons();
//Iterate over each icon on the page and replace if necessary
if (!haveFont)
$('[class^="mce-i-"]').each( function(e) {
console.log("Found element = ", this);
// Replace all <i></i> with <img>
....
}
}
This works fine for all our custom Html.
The Problem:
For some reason it will not work for tinyMCE <i> tags.
I have adjusted the class prefeix to allow for the TinyMCE 'mce-i-'.
It finds no elements in the DOM with 'mce-i' even though I can see them using firebug.
I have even set a timeout on the call to do this check, incase it was an issue with the DOM not been fully rendered yet. No luck.
Questions:
1: Any ideas on why no TinyMCE elements are not been found?
2: How can I update tinyMCE to use images directly instead of web fonts?
Thanks
I can't take credit for this, but I found a font-free, custom skin that replaces the fonts with images. I added the skin, updated my init method and it appears to work as I'd hoped.
It can be found here:
- https://pollyshaw.wordpress.com/2014/02/03/a-font-free-skin-for-tinymce-version-4/
- https://bitbucket.org/pollyshaw1/tinymce-4-lightgray-no-fonts-skin
In my app I want the user to type names into a UITextField (or equivalent) and then when they press return, it will put that word(s) in a blue bubble that's usually associated with tags. The cursor then moves to the end where they can add more "tags".
This can be seen when adding contacts in the To, CC & BCC fields in the Mail app, and also when selecting contacts in the Messages app.
How is this done? Is it something that's provided in the UIKit or available somewhere else?
Many thanks,
Michael
Venmo just open sourced their token field.
https://github.com/venmo/VENTokenField.git
edited:
The equivalent control in desktop Cocoa is an NSTokenField, but there doesn't seem to be an equivalent for Cocoa Touch.
Since iOS 13 there exists UISearchTextField.
https://developer.apple.com/documentation/uikit/uisearchtextfield
You can see that component in action in the Photos App.
That should fit for many use cases. By removing the leftView you can also get rid of the search icon.
But be aware: You can‘t mix text and tokens at various positions.
From the docs:
Tokens always occur contiguously before any text in the search field.
Adding this here for reference:
Feel free to check out TaggerKit (a library I made), it's more or less what OP was talking about. You can basically add tags functionality to your app by just adding a view and a couple of properties.
I dont think you can do it with any built in functionality in the SDK, never seen such a feature. What you could do however is implement it yourself, have some custom blue button with some text over it, and when the user hits return you can have some code that takes the text and returns you the button that you need, shouldnt be too bad to implement
Using Woodwing, we have a page that has custom html in it, using the custom web widget.
That widget has an anchor tag, that when tapped, opens a page in safari.
However, if we create the same page using the HTML widget, and a link overlay, that triggers a ModalView to display.
I'm assuming this has something to do with WoodWing's (un)documented protocols for the anchor tags, that are captured by the WoodWing shell application and used to trigger the "ModalView" display. Since everything in Woodwing generates an XML that is parsed when the app is loaded, and I've done numerous applications, this seems reasonable. However, there is very little technical documentation.
My question is: does anyone know any documentation on those protocols, or a way I can use custom-html to trigger the ModalView? I've tried replacing "http" with "ww" but no dice. It's possible it's javascript but I'm suspecting protocols...
The UIWebViewDelegate defines the webView:shouldStartLoadWithRequest:navigationType: method that your view controller can implement. In this implementation, your code shoudl decide if it wants to handle the request (user click) or let the UIWebView handle it normally.
For displaying a modal as a result of a click, this method would display the modal and return NO.
The default HTML widget implementation doesn't support this out of the box. There are two ways that you can do to achieve this;
Implement what they call a 'custom object'. They documented this feature, if you have access to their documentation this should be relatively easy to figure out. It allows you to write native objects and inject them into both the .ofip format and the application.
Implement a modal dialog within the widget (in HTML). This is less convenient but possible to do (if you have a fullscreen widget).
Create the specific URL for open as you mention in your comment(ww://string.string).
Then in UIWebView Delegate method (webView: shouldStartLoadWithRequest: navigationType:) get the redirect URL. If redirect URL is equal to you mention before then perform your action.
Let me know if this answer help you.
Thanks,
Simple question.
I have a UIWebView. It displays plain html text with a few headers. I want VoiceOver to read the content of this web view.
It would also be nice if I could make use of VoiceOver's rotor to let the user scroll through content using headers, but I won't get greedy yet.
Any input is appreciated.
What I have learned: If the view that the UIWebView is contained in is marked as accessibility enabled then voiceover will not pass through to the UIWebView.
UIWebView should be accessible with VoiceOver without you doing anything.
read this one :
http://arstechnica.com/apple/guides/2010/02/iphone-voiceservices-looking-under-the-hood.ars/
From the iOS developer documentation for accessibility.
A user interface element is accessible if it reports itself as an accessibility element. Although being accessible is not enough to make a user interface element useful to VoiceOver users, it represents the first step in the process of making your application accessible.
You can do something like this (or manually set a label):
[_view setIsAccessibilityElement:YES];
There is a lot of information here. I suggest that you consult this.
http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/iPhoneAccessibility/Making_Application_Accessible/Making_Application_Accessible.html#//apple_ref/doc/uid/
I am trying to run javascript on UIWebView and so far everything has been great, but I got a problem where I need to change a value in selection box, I am doing this document.getElementById('dt').selectedIndex = 5; somehow UIWebView won't change it, I can read the value perfectly, but somehow it doesn't change.
You can try to parse the HTML of the page, and change the selected value. Because the HTML is available for you when a page is loaded, it shouldn't be hard to do a replace or whatever.
If you want to use javascript, check this link