How do I disable copy, paste and select functions in a UIWebView that is showing a PDF file? - iphone

My app has a UIWebView that is used for showing a PDF file. The file size is less than 1MB but when the user double taps the screen, the app freezes and crashes a few moments later.
I think that if I disabled the select function, maybe this problem wouldn't occur. How do I do that?

Have a look at the console output. It looks like you are not handling tap events properly. You must have those handlers even if you want to ignore tap events (i.e. do nothing and return).
Here's a good overview of what needs to be done:
http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way/

Related

How to close System dialogs that appears on app crash?

I'm using xcuitest framework to automate mac application. I get system dialogs when the app is opened again after it crashes. I want to handle the dialog programmatically. But the dialog appears under the process `UserNotificationCenter' instead of the application under test. How can I handle the alert in such case?
You have two options:
Use InterruptionMonitor (documentation, use-case). This
approach is however kinda old and I found, that it does not work for
all dialogs and situations.
Create a method, which will wait for some regular app's button. If the app's button (or tab bar or other such XCUIElement) is visible and hittable after your app started, you can proceed with your test and if it's not, you can wait for the UserNotificationCenter dialog's button and identify&tap it by its string/position.
I'm using the second approach and its working much better, than the InterruptionMonitor. But it really depends on your app layout and use-case.
You should be able to revent it from appearing in the first place. Something like:
defaults write com.apple.CrashReporter DialogType none

How to copy to the UIPasteBoard from the Quick Actions menu without entering the app?

Is it possible to directly copy a value from a shortcut item without entering the app? I want to do something similar to Apple's Calculator App:
This is not possible as of now, otherwise the user would not be able to figure out if anything happened or not.
And for the calculator app, when you tap copy result it opens the Calculator app and then copies the last result.
You can do somewhat similar by showing a view controller that shows result copied or something similar.

Anyone implemented/used Mobile Device Screen Orientation plugin?

Has anyone successfully implemented screen orientation plugin in Sitecatalyst to capture mobile device orientation?. When we use the below code in the s_code, in the web page i am seeing some unusual behavior(ie: when we scroll the page to the bottom and then if i click anywhere on the content section, page goes to the top by default). I understand, that's happening because of this line "window.scroll(0,0)". Any help or thoughts?
Plugin Code below:
function screenOrientation(){switch(window.orientation){case 0:case 180:return("Portrait");break;case 90:case -90:return("Landscape");}window.scroll(0,0)}
Reference: [http://webanalyticsland.com/sitecatalyst-implementation/capture-mobile-device-screen-orientation-in-sitecatalyst]
Thanks in Advance.
This is clearly a code bug (or more a typo I think) and the line window.scroll(0,0) can be safely removed from the 'plugin' (its not really a plugin, just a js function that returns the orientation).
The reason this fires every time a user clicks on anywhere on the page is because you have ClickMap functionality enabled in your s_code.js configuration. This will fire an s.tl() everytime a click event occurs. the s.tl() will call the screenOrientation() function to populate your required prop/eVar.
So if you were to turn off clickMap (s.trackInlineStats=false;) this random scrolling to the top would stop even if you didn't remove the offending line. That said, remove the scrolling code, its not right or required!

Prevent cached iPhone webapp from reloading (scrolling to top)

I have an iPhone webapp that uses a cache manifest to work offline. I add the webapp to my home screen, use it (say scroll to a certain location on a page), then go back to homescreen.
When I open the app again, for a brief moment I see where I used to be (at that scrolled location on that page), but then the app "reloads" and I get scrolled to the top of the mainpage. Is there a way to prevent this "reloading"? This happens even in airplane mode (ie everything is working off the cache).
You're just seeing the default startup image, which is just a screenshot of the last place you were at. It's not "reloading"; the app wasn't loaded to begin with.
Search for "apple-touch-startup-image" to set a real loading image.
What I'm struggling with here is that the app actually seems to stay "in memory" longer if I use regular Safari as opposed to running in "apple-mobile-web-app-capable" mode. In the later case something as simple as pressing the home button, then task-switching back to the app causes a reload. Doing the same thing just in Safari often does not reload. So I'm worse off by using "apple-mobile-web-app-capable".
I don't believe there is a real 'reload' event. onload and onunload are all we get.
the onload handler starts up as if it is your first time coming to the page.
the onunload handler is the key to clearing out old content.
I like to provide alternate content for people who are coming back to my web app.
window.onunload=function(){
document.getElementsByTagName('body')[0].className+=' unloading'
}
And let the CSS do the dirty work to hide most of the body and show alternate content.
(this answer does not rely on jQuery or other frameworks)
// on load
window.scroll(0,0);
To ensure no old content is displayed while launching I use this in my page:
window.addEventListener('unload', function() { $('body').hide(); } );
Thus the last state of the page is empty and is what is shown to the user when the page is opened again.

UIPasteboard Cut Paste Select buttons not showing up as expected

Experiencing the following behavior in all of our UITextViews. Have not seen any posts on this issue to-date.
First entry into the Application works as expected (Can paste, select, cut or copy text).
After exiting application and reentry, standard UIPasteboard buttons do not show up.
This effects all UITextViews in the app. There is no custom UIPasteboard code.
Spyglass and blue text selection handles will display without menus. The symptoms appears as if [UIMenuController setMenuVisible:NO] has been called. We have no code that does this.
We simply want Copy and Paste to work consistently for our UITextView's.
If we reboot the phone, or delete and rebuild the App, it works fine the first time executed, and then ends up in this state from the 2nd execution on.
What might we be doing that would be triggering this behavior?