I'm new to programming with cocoa. I was going to experiment with the webkit View class. According to this page:
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/WebKit/Classes/WebView_Class/index.html
a web view should have a method called "setMainFrameURL". However, when I try to use it, I get an error message saying that the method is not defined. How is this possible? Does this method really exist?
setMainFrameURL is an Objective C method. The equivalent Swift syntax would be
webView.mainFrameURL = "http://www.google.com"
Related
I am developing an application using Xcode 7 and Swift 2. I recently discovered an error in my code. In the debugger log (I think that is what it is called) , it printed this:
[AppDeveloper] ADBannerView: Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:): Error Domain=ADErrorDomain Code=7 "Ad was unloaded from this banner" UserInfo={ADInternalErrorCode=7, NSLocalizedFailureReason=Ad was unloaded from this banner, ADInternalErrorDomain=ADErrorDomain}
I did some research and found out that I needed this code:
iAdBannerView.delegate = self
In my viewDidLoad method. I tried it, and I no longer recieved the error. However, I have two viewControllers. Both contain iAds. In the original view controller, ViewController.swift, the code workds. In the view controller that I later added, AboutViewContoller, I get this error:
Cannot assign a value of type 'AboutViewController' to a value of type 'ADBannerViewDelegate?"
Could someone please show me my error in my code?
Earlier, I had:
class AboutViewController: UIViewController {
I forgot the ADBannerViewDelegate. The correct code is:
class AboutViewController: UIViewController, ADBannerViewDelegate {
Thanks to Charles A. and Daniel Storm for helping out!
I a Zend Framework 2 custom view helper I use:
$uri = $this->view->vars()->mainMenu->findById('h');
The mainMenu property is a Zend\Navigation\Navigation object.
The result is that rendering of my view script stops at the point of executing the view helper without any error message. So for all practical purposes: the white screen of death.
In this view helper the line:
$uri = $this->view->vars()->mainMenu;
does work, so apparently the issue is with the findById() method.
But if I use the first line directly in my view script, I do get the expected result, a string containing the url of my home page: '/'.
My question is:
What is the issue with the findById() method in my view helper?
and/or (more importantly):
How can I debug this (and other, it is a recurring problem) issue in the view helper environment?
The Problem is that findById() doesn't exist. Check the Zend\Navigation\AbstractActionContainer which the Zend\Navigation\Navigation extends.
The correct method (i guess) would be findBy(), findAllBy() or findOneBy()
$this->view->vars()->mainMenu->findOneBy('id', 'my-id-to-find');
Found the issue by first addressing the second part of my question, by installing XDEBUG (on Zend Server CE) which finally gave some error output (calling method on non-object).
Where I was focusing on my layout view script, the same view helper also existed in my (final) view script where the navigation object was not available under the reference I used.
What works in both view and layout script is:
$uri = $this->view->layout()->getVariables()->mainNav->findById('h');
I found my solution here:
http://akrabat.com/zend-framework-2/access-view-variables-in-another-view-model/
I have a small issue I was hoping somebody could help me with. I have to call the NavigationService.RemoveBackEntry() on two of my views due to the way I have my first run wizard set up.
This method needs to be called on the view (in the codebehind) as far as I am aware and cannot be called in my view models.
I was wondering what would be the easiest, cleanest way to call a RemoveLastNavEntry() from the ViewModel if the method lives on the view.
Rob has said it is a feature he will build into the navigation service at some point but until then I need to implement this as a minor hack.
While this truely is a task for the view, you can, if you really want to, call it from the ViewModel, as a static call.
(App.Current.RootVisual as PhoneApplicationFrame).RemoveBackEntry()
See PhoneApplicationFrame.RemoveBackEntry Method for documentation.
I have the same problem, as in this question. Did anybody find any solutions for this?
So I can't do like this:
flash[:notice] = "Successfully created #{#template.link_to('product', #product)}.
or like this:
#template.title("Page title is here.")
It worked perfectly in Rails 2.3. The main idea is to find out, how to use helper methods directly from conrollers, not from views.
Thanks.
You're doing it wrong.
First, you should setup the title of a page inside the view, not in your controller.
You can simply place a call to the title helper within your view file.
About the link, flash shouldn't contain HTML. However, you can create the link manually.
flash[:notice] = %Q{Successfully created product.}
I ran into this same problem as well and found that you can use the view_context method.
API documentation here: http://api.rubyonrails.org/classes/AbstractController/Rendering.html#method-i-view_context
I have to implement an Form View, or in other words: A class that is used to put a complex input form on the screen.
The Form is built up of FormComponents. There is an addFormComponent() Method to compose the form with these. And then, the form has an isValid() Method which will go through all the FormComponents and check their associated FormValidators.
For sure this thing has a lot of "intelligence", but most of this is just a call to some other class. For example the isValid() method does cool stuff, but it really only calls the isValid() methods of the FormComponents which are registered in an array. Nothing too fancy.
Well, that beeing said, must I make a fat FormViewController for this, or is an View just fine?
My understanding of these is, that a ViewController is used when there's some big logic involved. In this case, the Form View has a template which will simply iterate over the FormComponents and include them. Each FormComponent has it's own template in turn and does it's own stuff.
I've always been struggling with ViewController and View and I think I'll keep on doing that until I get a nice R.I.P. brick... but maybe someone can clear this up a little bit ;-)
The purist in me is saying that this belongs in a ViewController. I guess maybe it would depend on the framework you are using. For example, this type of setup would be very easily implemented in a Spring Controller object. It sounds like creating a controller in your case would be a lot of extra work.
Nothing is ever set in stone. You can implement in the View for now and if this turns out to be a huge burdon, move it to a Controller class. Knowing when to refactor is the difficult part.