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

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.

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

Function across multiple view controllers

I am trying to make a function so that I request a 'manager override' where it presents a screen for a manager to enter their password and press an approve button. How should I do this? Will it have to be in multiple functions? Is there a way that I can call one function and it present the information back? Would a completion work for what I need? I have no ideas where to start for this.
My set up is as follows:
A view controller asks for manager approval, then a screen slides up with text boxes and an approve button. I want the approve button to trigger authenticating and dismissing the screen
Assuming you don't want a Framework target (that sounds like overkill for what you want) simply mark the function as "public" and move it outside of any class. I just tried in a sample project and it works.
It looks important - remember to keep it in a file already in the project. (My sample project didn't work with menu option File|Add|New|File.)
Now, if you really want portability, check out how to create a Framework project.

Property additionalActions of NSUserNotification seems not working?

To understand NSUserNotification better, I wrote a little test app playing with this class.
So far so good, except that no matter how hard I tried to feed the additionalActions property with array of NSUserNotificationAction objects, it never showed any difference but only one action button and a close one.
My expectation for this property is that the notification would show a pull-down menu containing the additional buttons I offer as it does in the Mac App Store update notifications.
Am I missing something? Or are you having the same problem, since it is a bug awaiting Apple to tackle?
Can you please try to click and hold down the action button in your notification? Does it show a drop-down menu of additionalActions?
Update
As it turns out, you can show the little chevron next to the action button by setting a true value for the private _alwaysShowAlternateActionMenu key on the notification. In Swift 3, it would look like this:
notification.setValue(true, forKey: "_alwaysShowAlternateActionMenu")
However, as I mentioned this is a private API and I strongly advise against using it if you want to distribute your App through the Mac App Store.
It is probably a bug. Setting up additionalActions will create the list, but not the little arrow icon. Holding down on actionButton will show the menu with the number of actions you set.
Besides setting additionalActions will cause several other problems. I will save this for another question.
Refer to another question.
show NSUserNotification additionalActions on click
P.S. I am using El Capitan APIs

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

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/

How to create android app running on top of another app

I want to develop a program like button savior (which runs on top of a another app and we can press menu, back buttons on top of a running app). So user do not need to press hardware buttons to access menu, back functionalities.
I want to do the same but to do it I have to run a app on top of another app.
How can I do this?
-Lasith.
Take a look at Robotium: http://code.google.com/p/robotium/
It seems to be doing what you want to do. You can take a look at the code and figure out how to do it.
Well i think that what you are looking for is creating something like Input Method (IME), there is a good tutorial to start with on Android Docs, another thing you can do is to create an activity which contains your virtual controller, distribute that as a lib and then if someone need it they can downloads and register your component into their project, something like what AdMobs does.