I created a simple test app where one field is an NSTextField and another is a <textarea> instead a WKWebView. I can click into the web view once, but if I go back to the NSTextField, I'm unable to get the cursor back into the web view ever again.
Here's a demonstration:
As you can see, the web view is still interactive to some extent, it just can't become (I assume) the first responder again.
Is there something weird about WKWebView and the responder chain? How can I make the WebWebView behave like a normal NSTextField?
Here is a sample project built in Xcode 11.5 in case you want to try it out.
How can this be fixed?
The issue seems to be related to the textarea, using content editable <body contenteditable="true"></body> does seem to work.
A workaround for using the textarea is to subclass WKWebView like this:
- (void)mouseDown:(NSEvent *)event
{
[super mouseDown:event];
[[self window] makeFirstResponder:self];
}
Related
I have a custom UIView built using several UIButtons. In the viewDidAppear function of a ViewController I take the subviews of this UIView and attach an addTarget to them. Everything works as expected and the embedded UIButtons acts according to the tap events added, selecting and de-selecting the buttons.
But when I instantiate a new ViewController, show it and then it is dismissed, when I'm back to the parent ViewController, the added events are not responding anymore. The rest of the elements of the parent ViewController work (UITableView, other buttons, etc...). This only happens in iOS 12, both simulator and iPhone. In iOS 10 - 11 works like a charm.
What I've seen is that, in IOS 12, when I dismiss the viewController and I'm back to the caller ViewController, no viewDidAppear is being called.
I've lost a couple of day looking for a solution but nothing seems to work. The UIButtons inside my custom UIView class, are responding because I placed some "print()" inside their native tap events, and I get a response when tapping, something must be wrong when I define the addTarget in the ViewController.
Lately I added a UIButton that triggers the function which attachs the event. If I tap on it, the buttons become responsive again. If I call the function as a callback of the Dissmiss method in the Second ViewController... doesn't work. It's like the ViewController wasn't active when I'm back to it.
Must say that the viewControllers are placed inside a Navigation Controller which is inside a Tab Bar Controller.
Any idea?
Disabling "Clear Graphics Context” made the trick... I don't know why, but I suppose it's the XCode Magic that nobody understand.
I am using Xcode 6 and my project is in ARC mode. In my project, I hook up segues in the storyboard. So far I believe I only used the 'Push' segues. I was wondering, when I do activate this segue, does the previous view controller get deallocated? For example, i am using a 'Push' segue to go from a login screen to the home screen and I want to make sure the log in screen is not hanging around. If it is, how do I deallocate it?
If you want to deallocate it, you can release something in viewDidDisapper.`
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
//TODO: release something
}
`
You don't need to manage in the ARC mode ViewController destroyed, only need to handle something need to manually shut down or release, such as NSTimer.
I'm a noob OSX Developer having issues getting a WebView to load a URL when inside of a Custom View using NSPopover...My NSPopover is activated when a notification bar item is clicked.
This code is in my application delegate under
"- (void)applicationDidFinishLaunching:(NSNotification *)aNotification":
NSURL*url=[NSURL URLWithString:#"http://www.google.com"];
NSURLRequest*request=[NSURLRequest requestWithURL:url];
[[_webView mainFrame] loadRequest:request];
It works just fine if I move the WebView to any other window, but the WebView in my Custom View for this NSPopover displays as a blank page. Any ideas why? Any additional information you might need? Limitation of the CustomView?
You have created the Outlet in IB for the UIWebView in your Custom View ? and strung it together?
I'm developing an iPad app that supposed to output a website to another view, but when the second view loads, it comes up null. I'm using storyboard to link a button to push the web view controller and load the webpage into that view. The code works fine in the first view (indicated by NSLog), but NSURL never makes it to the second view (NSLog "Null").
Code in IBAction on first view:
self.sanctuaryWebViewController = [[SanctuaryWebViewController alloc]init];
self.sanctuaryWebViewController.URL = [NSURL URLWithString:#"http://www.website.org"];
Code in ViewDidLoad Second View Controller:
NSURLRequest *requestObject = [NSURLRequest requestWithURL:URL];
[webView loadRequest:requestObject];
I have done this in an Iphone app fine declaring a nav delegate to push the view, but not sure if using storyboard or splitview has anything to do with the problem. I spent hours searching for help and tried several different ways to code, but no go. I think I'm close, but not quite there. Using Xcode 4.4 and running on OS 10.8; IOS 5.1
Thanks for any suggestions
Can you show us more of the second view controller's code? I'm assuming you are using ARC? I assume you mean the result is coming up nil rather than NSNull (there is a difference)? Have you connected the webView in the second view controller to the UIWebView in the Storyboard/IB?
Good luck!
I was declaring UIWebview twice. "webview" and "_webview". I removed the instant variable declared in .h and kept the property. Made sure "_webview" was used. Also, Since I linked a segue to a button, I got rid of the IBAction method and replaced it with the prepareForSegue method, which calls the segue. Really had know idea what I was doing using storyboard. I knew about the segue methods, but did not realize they are not linked to the button like IBAction methods. They seem to be used in similar way as calling xib files, but calling segues.
I wrote an app that has about 3 different view controllers for each view in the tab bar. I called applicationDidEnterBackground: in each of the view controllers to save all the data in that specific view after the home button is tapped. This runs flawlessly on the iPad simulator, but for some reason, it crashed after trying to edit the data on the iPhone simulator. I thought this is probably an issue with putting the applicationDidEnterBackground: in the view controller, but if that was the issue, then wouldn't it crash on the iPad simulator as well?
I know that I should put applicationDidEnterBackground in the app delegate, but my method looks sort of like this:
- (void)applicationDidEnterBackground:(NSNotification *)notification {
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:firstField.text];
[array addObject:secondField.text];
[array writeToFile:[self dataFilePath] atomically:YES];
}
If I put this in the App Delegate, of course it doesn't recognize firstField or secondField because I did not declare it in header file or synthesize it or anything. If I were to declare everything in the App Delegate, then the outlets in my nib file will fail because each of the File's Owner's class is one of those specific view controllers.
Is the placement of applicationDidEnterBackground: not even my issue since it runs fine on the iPad simulator?
Also, it used to run fine on the iPhone simulator as well. I changed the Image View's background on all of the nibs, then this started happening. I rechecked all my outlets and actions and they match up fine.
EDIT: I fixed it. Turns out I had an extra field that I decided to add to the iPad's nib, but not the iPhone's. I though it would be fine, not the case though. That explains all the weirdness that was going on. I deleted the field in the iPad's nib and everything is A Okay. Phillipe, thank you so much for your help and offer to look it over for me, that is incredibly generous.
I fixed it. Turns out I had an extra field that I decided to add to the iPad's nib, but not the iPhone's. I though it would be fine, not the case though. That explains all the weirdness that was going on. I deleted the field in the iPad's nib and everything is A Okay. Phillipe, thank you so much for your help and offer to look it over for me, that is incredibly generous.