I have a problem witha UITextField.
Context:
I have a UITabBar Controller with 5 Tabs. Each one has a NavigationController with their related ViewController.
First Tab, has a UITable. When a row in the table is touched, the user is sent to the second tab, and a new view is pushed in the NavigationController.
This new ViewController has a UITextField. When I touch it, the App Crashes with the message in console:
"-[CALayerArray registerDefaults:]:unrecognized selector sent to instance 0x612f280
***Terminating app due to uncoaught exception 'NSInvalidArgumentException', reason: "-[CALayerArray registerDefaults:]:unrecognized selector sent to instance 0x612f280"
Also I've noticed this ViewController also is not responding to Orientation Change... so I assume is something related to the tree...
Everything was constructed with the Interface Builder.
If you have any tip or idea of what can be happening, I'd really appreciate it.
Thank you very much.
in IB, deleting and adding a new UITextField should do the trick.
Related
I have a Notes-like app: UITableViewController showing up individual notes by pushing them onto navigation stack.
The problem arises when I have UITextView with the FirstResponder status (keyboard is shown) and I touch Back button. The current view controller is dismissed with the animation as expected, BUT the navigation bar is broken now! If I press any of the bar buttons, it will cause EXC_BAD_ACCESS.
I would say that it was not transitioned properly. The table VC is broken somehow as well, as it may appear empty on further manipulations... Very strange behaviour!
By the way, it did not cause any problems with iOS5 and iOS6, but there I used a custom chevron Back button.
I've checked the standard Notes app and it works like a charm.
What is the trick?
Thanks a lot for your advice!
EXC_BAD_ACCESS means you are trying to access an object that has been deallocated. Best thing you can do to trace this is enabling NSZombie, it will tell you what released object is being sent a message (aka EXC_BAD_ACCESS).
You can get how to enable it from here.
I got it and will try to explain to help somebody else to save their day...
EXC_BAD_ACCESS was raised because UITableViewController was not properly transitioned to during Back pop-animation (its viewWillAppear: and viewDidAppear: method were not triggered at all).
In its turn, the animation was not properly performed, as popViewControllerAnimated: was called twice or even more times: 1) as part of the system Back-button callback; 2) inside textViewDidEndEditing: in case no text was entered.
The solution is to check whether the back button has been pressed before calling popViewControllerAnimated:. The trick is to check if the detail-view controller is still in the navigation stack.
Here is the helper method:
-(void) returnToTheListOfRecords {
self.textView.delegate = nil; // this is to avoid the second call of `textViewDidEndEditing:`
if ([self.navigationController.viewControllers indexOfObject:self.delegate]==NSNotFound) {
// Back button has been pressed.
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}
The problem happens on iOS7 only due to its brand-new animation.
I have the following scenario:
UIViewControllerA pushes UIViewControllerB on to the navigation stack via a storyboard segue;
UIViewControllerB is now currently onscreen and I simulate a memory warning via the iOS Simulator.
UIViewControllerA.DidReceiveMemoryWarning() gets invoked as well as UIViewControllerA.ViewDidUnload().
In method UIViewControllerA.ViewDidUnload() I call ReleaseDesignerOutlets() as recommended. UIViewControllerA designer outlets are now deallocated and null.
I hit the "back" button on the navigation bar which dismisses UIViewControllerB and causes UIViewControllerA.ViewDidLoad() to be invoked.
At this point I would expect the designer outlets to be initialised but they are still null and my application crashes due to null pointer exception.
Have I fundamentally missed something? I am using the Monotouch 5.4.0.
EDIT
I found this post which describes the solution to problem to be the same as what I discovered, that is, don't release the designer outlets in ViewDidUnload().
Update: It's finally crash free! (or at least it seems to be)
For future reference, it looks like the big lock-up was due to my disposing of my UIWebView outlet in the ViewDidUnload event. The UIWebView is defined in the xib, and not added as a subview in code.
When memory was running low, the view unloaded and removed the UIWebView outlet. Subsequently, the ViewDidLoad event would fire again, as the app recovered (!?), but it would lock-up. I expected the UIWebView to be reinstated in when the view reloaded (i.e. the xib reloaded).
Is this not the case? I thought it was good practise to dispose of outlets in the ViewDidUnload event?
As soon as I commented out the "webView.Dispose(); webView = null;" line of code, it's been working as expected.
What a day!
EDIT
Further debugging reveals that SOME designer outlets are getting reallocated such as UIImageView and UIScrollView, others such as UITextField and UIBarButtonItem are not.
I have a problem that I've been sitting with all the day. I have a super view which contains UIPageControl and UIScrollView, in this super view. I have created a sub view which contains three images, three labels, and three buttons. Each button has a touch up event. When the button event is triggered the super view will be promoted by a new view. For doing that, I created a segue which connected with super view and new view. Here is the connection code in the super view.
`
<connections>
<outlet property="pageControl" destination="ivy-0Q-UQo" id="rGm-sh-mdE"/>
<outlet property="scrollView" destination="4Yu-Qb-kbF" id="aqY-ou-cv4"/>
<segue destination="zZo-CH-P2Y" kind="push" id="xBU-ZO-u7s"/>
</connections>
`
This piece of code will guarantee the connection between the super view and the new view is okay,
here is the touch up event code.
WelcomeFrameViewController *welcomeFrameVC = [WelcomeFrameViewController alloc]; //super view instance
NSLog(#"=======================");
[welcomeFrameVC performSegueWithIdentifier: #"ForwardToLogin" sender: self];
When I run the program, the compiler complains with
2012-08-20 10:17:02.325 TTRen[2440:f803] ============44===========
2012-08-20 10:17:02.352 TTRen[2440:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver WelcomeFrameViewController: 0x688e960 has no segue with identifier 'ForwardToLogin''
I am quite new in iOS, any suggestions will be deeply appreciated.
'Receiver WelcomeFrameViewController: 0x688e960 has no segue with
identifier 'ForwardToLogin''
In your storyboard, check that you actually have a segue named "ForwardToLogin"
There does seem to be a bug with xCode (still in 6) where storyboard changes you make aren't get copied to the simulator. You can reset the Simulator's Content & Settings to resolve this.
Other things to check:
Check the naming of your segue. Check it again. Check it some more :-)
Ensure that your segue is pointing in the right direction. It needs to point away from the UIViewController that calls performSegue….
Ensure you don't have two copies of your view controller on top of each other, with the segue attached to the one on top, and you instantiating the one underneath!
There's a similar question here and I encountered the same problem too. The reset fixed it for me.
Forgive me if this has been asked/answered already but I couldn't find it anywhere (at least no in Monotouch - vaguely answer for ObjC. So completely new to Monotouch but I have everything completed in my application that I want with one exception. I'm trying to update a parent of a subview.
Here is the scenario:
I have a UINavigationController with a UIView (not a table) which has a few buttons on it that directs via a PushViewController to a Subview. I make some changes on the subview, which I would like reflected back on the parent. I can of course add a manual refresh button if I wanted but was looking for something a little better.
I did see some things that referred to using a viewWillAppear but couldn't find any good examples. My attempts failed pretty bad, so any suggestions would be great.
Thanks,
Richard
If you have a UINavigationController, it has a "back" button on top. Once this is hit by the user (or if you pop to a previous view controller), the currently view controller shown will trigger ViewWillDisappear and ViewDidDisappear and the view below (the one with your buttons) will fire ViewWillAppear and ViewDidAppear. Just overload those and update your UI state in there.
I have a window based applicaiton with tab bar and navigation bar integrated into it. On the navigation bar have a custom button which opens a table view.
On clicking on the cell of the table I want to open a new table view controller. But as soon as I click on the cell of first table I get an exception that
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'AddForm''
I have checked that AddForm is in right place.
I have tried all the solutions given above and on other thread, but still stuck. I hope someone can help me.
The flow is something like this
ListButton (on click opens a list view) -> a table view opens -> (on click of a cell should open a new table view Controller and fetch data from core data)
My root view controller code is in the second table view controller file... is that what I am doing wrong? I am doing so because I don't need the core data before that....
Please help
Thanks in advance
I Used to have the same problem first of all check in your AppDelegate.m class if the managedObjectContext is created
if it is created check if it is pass it as argument
something like this
MasterViewController *controller = (MasterViewController *)masterNavigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
if that is correct for you main view just be sure that you are passing it through your views something like this
self.detailViewController.managedObjectContext = self.managedObjectContext;
well at least that works for me =)
The most common cause of this problem is misspelling the name of the entity or getting the capitalization wrong. Check that AddForm is spelled exactly the same in the code and the data model editor.