Error when clicking any UI element in Xamarin.iOS - xamarin

I have an issue with an iOS app I'm working on (https://github.com/nodoid/WeatherApp). It builds and deploys fine but when you hit any UI element that isn't a label, it crashes with an error such as
ViewController btnGetWeather unrecognised selector sent to instance
Error: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: ViewController btnGetWeather unrecognised selector sent to instance
It's been a long time since I've done anything with iOS native (I was still using xibs!). It looks like everything is correct on the storyboard but I'm at a loss as to why this is happening given everything builds.
I've done the usual trick of deleting the obj folder in the iOS project, but still get this issue.

I downloaded your code to try it out. When I click the button, the error message :Name: NSInvalidArgumentException Reason: Application tried to present modal view controller on itself. Presenting controller is <UIAlertController: 0x7fb648008a00>.
I found the reason for this problem: In the ShowError method of your ViewController.cs, you use the alert.PresentViewController() method, you need to change the alert of this line of code to "this.PresentViewController()".

Related

Why is my app crashing - 'NSUnknownKeyException'?

Im having an issue with Xcode where its crashing on references to old variables which I have deleted, the error message is
*** Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<mydoncaster.OptionsView 0x11fd94eb0> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key restaurantLabel.'
I don't know why its moaning about restaurantLabel when that no longer exist in the specific view controller, I can delete everything out of the view controller and from the storyboard and build it all again and it still brings up the error, I've also tried building and cleaning my code but it still happens, is this a saving issue or something else.
Search for "restaurantLabel" in your storyboard.
There should be an outlet somewhere in "Referencing outlets" section, which you've forgotten to delete.

Code erroring upon editing, but fine when building

All of my code is fine when I build/run the application; whenever I edit it, up comes a lot of error messages with errors such as
"Use of undeclared type '-object type-'"
as you can see in the picture below. From what I have observed, it happens after #NSApplicationMain but if I remove it, the code errors for good. Any insights on why this happens?
It also terminates itself when I run it with the error "an uncaught exception was raised". The app gets terminated on line 29 where the AppDelegate class is defined. I put the error log in a GitHub Gist here.
I was on an old beta of Xcode 6.1.

Interface Builder XIB Compiler error

I get this error message when connecting two UISwipeGestureRecognizers to a single view in my project inside of a XIB file (though not in a new project, curiously). Anybody know what this error means? It is a compile error, not a runtime error. I'm using Xcode 4.4 (this error doesn't happen on Xcode 4.5 actually). This is an error from inside interface builder.
Assertion failure in -[IBCocoaTouchToolObjectPackage connectionsByProcessingConnections:], /SourceCache/IBSimulatorComponents/IBSimulatorComponents-223/IBCocoaTouchTool/IBCocoaTouchToolObjectPackage.m:1132012-08-03 16:52:01.428 Interface Builder Cocoa Touch Tool[5646:11903] Exception producing nib: Mismatched addsContentToExistingCollection value for the coalescing outlet connection & one of its fragments.
I suspect this occurs because Interface Builder allows your outlets to get into an inconsistent state. It's a logic bug in Interface Builder that manifests as a run-time exception in the ibtool compiler. I was able to work around it by disconnecting the outlets and outlet collections I had recently created, and then rewiring them.
I was actually able to get rid of the error by deleting the entire Panel in the XIB, and then just undoing the delete. Clean + Build and the error was gone. Not sure if that will work for others as well.

Error: Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIApplication 0x6887a30> setValue:forUndefinedKey:]

The full error is: Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key.
So I have been trying what other people have been saying with similar problems. I have tried getting rid of every mention of landscapeView in the project, including the Connections in the FIle's Owner in the ViewController_iPhone.xib and then I started fresh by making outlets in the super class ViewController (since I want to use landscapeView and portraitView for iPad also) then I set up connections in ViewController_iPhone.xib and ViewController_iPad.xib to the UIView named Landscape in each respectively, and I still get this error.
I'm just starting out in app development so I'm trying to make a template for an app that is supportive of all orientations on both iPhone and iPad. Thanks for any help
EDIT: Here is a link to all my app delegate h and m and main.m : I am getting the Applications are expected to have a root view controller at the end of application launch error
EDIT 2: So I also tried to make landscapeView a property of ViewController and I made a setter method in ViewController.m but it still has the same problem.
I've found the most common place this error happens is when you instantiate a view from a xib from within a class that is not the xib's owner.
What I mean by this is you might be calling something similar to this:
[[NSBundle mainBundle] loadNibNamed:#"MyView" owner:self options:nil];
You're changing the owner, so you have to be sure that the class that self refers to has all the IBOutlet properties needed by "MyView". Usually this is done in Interface Builder, but in this case you're setting your owner programmatically, which means you can't make the connections in IB. When the IBOutlets aren't there, the app tries to make those connections and fails, giving the error you see.
My advice (without knowing any more info than you've given so far) is to check to see if you've made this call without having the proper IBOutlets.
I had to remove the NIB or XIB (or whatever they are this iteration) for the Main Interface.
It sure would be nice if Apple fully tested the broken software before unleashing it on the unsuspecting public. They could have handled the problem in any number of ways; but instead they chose a runtime crash and obscure [meaningless] error message.
Two main reason is follow
your iboutlet may break please check in storyboard or IB.
if you don't select module for custom class, see into your storyboard.
What I found is I deleted a WebView in viewcontroller.h , but haven't delete the xib file that point to this WebView !

Map View on Tab Bar project

I've got a tab-bar project in Xcode 4 and I'm trying to implement a map view on one of the tabs.
I've followed this tutorial: http://www.youtube.com/watch?v=ZrePrrHgXYA but I'm getting an error: Program received signal: "SIGBART" whenever I click the tab.
How come? Is it because the tutorial is only for view based projects? And if so, how do I get around it?
Error SIGBART can be shown when you don't import a Framework (like mapkit), o you try to use an object that has been released. Is a common error occurred when you badly connect (in IB o in code) with link pages or objects. You surely have done a big error in the code that prevent your app to run! Try to redo the last steps before the app stopped!

Resources