I have a UIWebView. In this, i want to catch when the user use the copy menu in order to copy selection into a pasteboard.
Afterwards when the user touch a button, the content will be paste in a mail.
I want to intercept when the user click on copy or cut menu. so i had this two methods :
- (void)cut:(id)sender
{
NSLog(#"cuuuuuuuuuut");
}
- (void)copy:(id)sender
{
NSLog(#"copyyy");
}
when i click on the cut menu, NSlog print cuuuuuuuuuut
but when i click on the copy menu , NSLog print nothing (copy method isn't called).
why ?
May I suggest UIPasteboard in the documentation? (Developer membership required)
Related
I am currently developing a cocoa web browser application like google chrome. I was testing it until I came across the problem that the wkwebview doesn't support full screen on videos. When I open a video, I get this message...
I thought I had to make the wkwebview a subview of the view, using this code
view.addSubview(webView)
I tried it and it still show the image above.
Can you please assist me on supporting full screen.
Open your project.
Right click on prject app grade folder from sidebar and click new file.
in choose a template click objective-C file.
name it for example WKPreferences and enter.
Now next window press create.
On next create Bridging-Header.
Now you can see two new files in your sidebar.
Paste following code in WKPreferences.m
#import <Foundation/Foundation.h>
Paste following code in Bridge-Bridging-Header.h
#import <WebKit/WebKit.h>
#interface WKPreferences ()
-(void)_setFullScreenEnabled:(BOOL)fullScreenEnabled;
#end
Now Paste following code in viewcontroller.swift
webView.configuration.preferences._setFullScreenEnabled(true)
Thats it.
You should be able to just put the following in the Swift-File where the WebView is created:
webView.configuration.preferences.setValue(true, forKey: "fullScreenEnabled")
I am working on a small desktop app that will open websites on the click of a button. It's sort of a bookmark launcher in app form. I need to be able to connect a button in Swift to a single line of HTML code and have the button execute the code.
This is not an iOS app, it is macOS only. I am not looking to launch a UIWebView, I just need a single line of HTML executed.
Can anyone help? Thanks in advance.
I don't understand what you mean by "execute html code"
if you have a link and want to open it you can do:
NSWorkspace.shared.open(url:"your url")
https://developer.apple.com/documentation/appkit/nsworkspace
I did a cocoa application in which the file dialog box is opening when a button is tapped with the use of NSOpenPanel controller in cocoa applications.For ipad applications we are using UISplitViewController.
I want to know that for developing the applications in iphone,what controller to be used for opening a file dialog box when a button is tapped.
For example in composing a mail.In composing a mail,if we want to attach any files from the local drive,we click the "Attach a File" button. Then it will opens a file open dialog box for selection of file what we want.
Can any one help me or suggest me what controller to be used for opening a file in iphone applications?For opening a file dialog box ,in
cocoa applications --------- Controller used is NSOpenPanel
ipad applications --------- Controller used is UISplitViewController
Like wise for i phone applications ------- ??????
Please help me out of this?
iOS doesn't have a concept of browsing arbitrary local files.
It does have the ability to browse for images from the photo library — for that you can use UIImagePickerController.
Other than photos, the only files you can even open are ones that are inside your own sandbox folder (i.e. ones that you've put there yourself). There isn't a built in view controller that will display them — you'd have to write your own that will read the list of files using something like NSFileManager contentsOfDirectoryAtPath:error:, and display them in an appropriate UI.
If I touch urls on UIWebView and hold 2, 3 seconds, it will display an option window for url with items:
Open, Copy
Is it possible to change the items or add new option? Such as
Open, Copy, Download
Welcome any comment
Not using UIKit's built in UIWebView, no. The only way to do this would be to rewrite/subclass it, but that's going to be a massive pain.
Note: Open and download are basically the same thing in iOS.
I have a WebView that loads a simple html page in my resources folder. The page contains links. When the user touches on a link to a Web site, the iPhone will close my app and open Safari. Since the user may not want to leave my app right now, I use:
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
to trap the link touch and show him an alert box, asking him to confirm that he wants to leave my app and go to Safari right now.
Same for an email link, which would close my app and open the user's email program.
However, if I want to similarly trap when the user touches a "tel:402-555-1212" phone call link, it works on the simulator, but on the real device I just get a simple alert box that says "call 4025551212": it clearly is ignoring my custom code for the telephone number link.
Is that a bug? It happens the same way (success on simulator, not on iphone) whether or not I select "detects phone numbers" for the webview in IB. How do I get this to work on the iPhone?
2) And very closely related question: if I click to allow the phone call to happen, when the phone call ends my app returns to its opening page, closing all other views. Is this normal function? There was no memory warning. Did the phone close and then re-open my app? It doesn't do that if click on a link and go to safari: when I close safari my app doesn't open again.
Thanks in advance for any insight.
--Steve
maybe you should set the detectsPhoneNumbers property to NO