NSConcreteMapTable backdropView:willChangeToGraphicsQuality: ...error - ios

I'm developing an iPad app to help me to manage my expenses when I'm abroad.
I have a split view with the classical master and detail views. In the master there is the list of the expenses and in the detail view, guess what? The details of every expense!
When I tap on a button in the detail a new view is loaded using a modal segue with a Form Sheet. The user insert a number and if that number is bigger than a certain value the colors of the labels in the master and in the detail will change.
When I save this number I dismiss the modal view and send a NSMessage to the master in order to reload the table with the new label colors and reload the detail view selected previously.
Everything work using the iOS Simulator, but when I run the app on my iPad (iPad 2), everything freeze and I got this message:
2013-11-09 21:52:04.763 IOUinTravel[562:60b] -[NSConcreteMapTable
backdropView:willChangeToGraphicsQuality:]: unrecognized selector sent
to instance 0x18b8fb00 2013-11-09 21:52:04.767 IOUinTravel[562:60b]
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMapTable
backdropView:willChangeToGraphicsQuality:]: unrecognized selector sent
to instance 0x18b8fb00'
* First throw call stack: (0x2df5bf4b 0x387386af 0x2df5f8e7 0x2df5e1cb 0x2dead4d8 0x30c88b43 0x306cd7b5 0x306cd6e5 0x306cd7d5
0x306cd6e5 0x306da5c3 0x306da417 0x30785f67 0x30785d83 0x3077de85
0x3077d30d 0x3077d07d 0x3077d015 0x306ceda3 0x30355c6b 0x3035147b
0x3035130d 0x30350d1f 0x30350b2f 0x306c70c3 0x2df271cd 0x2df24b71
0x2df24eb3 0x2de8fc27 0x2de8fa0b 0x32b70283 0x30733049 0x9a3d5
0x38c40ab7) libc++abi.dylib: terminating with uncaught exception of
type NSException (lldb)
I really do not know why and how to solve it.
The methods I've used are:
In the Form Sheet modal view:
- (IBAction)saveNumber:(id)sender {
// Do some stuff here
[self dismissViewControllerAnimated:YES completion:^{ [[NSNotificationCenter defaultCenter] postNotificationName:#"reloadAfterExpenseCheck" object:self];}];
}
In the main view:
- (void)reloadAfterExpenseCheck:(NSNotification *)notification
{
if ([[notification name] isEqualToString:#"reloadAfterExpenseCheck"]) {
NSLog(#"Messaggio ricevuto!");
NSLog(#"%#", self.indexPathToUpdate);
[self.tableView reloadData];
[self.tableView selectRowAtIndexPath:self.indexPathToUpdate animated:NO scrollPosition:UITableViewScrollPositionNone];
[self performSegueWithIdentifier:#"detailExpense" sender:self];
}
}
The segue #"detailExpense" works when I trigger it selecting a cell in the master table, so I do not know where is the problem... in the iOS sim it works!
Thank you for your answers.

I've solved this problem, I do not know it it is the best way but it works now.
I started to think that maybe there could be some asynchronous task going on. My Mac Mini cpu was fast enough to complete the first task, load the view and fill it with my data, the iPad cpu maybe was too slow so the view wasn't loaded... at least that is my guess.
I've simple added a NSTimer that fires the method used to load the detail view after a short time. The user do not notice the delay but it gives time to the iPad.
That's the code:
- (void)reloadAfterExpenseCheck:(NSNotification *)notification {
if ([[notification name] isEqualToString:#"reloadAfterExpenseCheck"]) {
[self.tableView reloadData];
[self.tableView selectRowAtIndexPath:self.indexPathToUpdate animated:NO scrollPosition:UITableViewScrollPositionNone];
//[self performSegueWithIdentifier:#"detailExpense" sender:self];
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:#selector(loadIt) userInfo:nil repeats:NO];
}
}
-(void)loadIt
{
[self performSegueWithIdentifier:#"detailExpense" sender:self];
}

Related

[_UILabelLayer isHidden]: message sent to deallocated instance

I have a UILabel and a checkbox button. When checkbox button is checked, display the uilabel,else display the label for 5 seconds and hide the label.When I go to other view and come back to this view,my app gets crashed saying "[_UILabelLayer isHidden]: message sent to deallocated instance "
NSString *display = [NSString stringWithFormat:#"Scanned!\n\nFormat: %#\n\nContents:\n%#", formatString, result.text];
if(checkbox==NO){
[self hideLabel:display];
}
//method to hide the label for 5 seconds
- (void)hideLabel:(NSString*)text{
self.decodedLabel.hidden=NO;
[self performSelector:#selector(hideLabel) withObject:nil afterDelay:5];//3sec
}
-(void)hideLabel{
self.decodedLabel.hidden= YES; //app crashed at this point
}
Could anyone tell me why this is crashing?
[self performSelector:#selector(hideLabel) withObject:nil afterDelay:5];
is causing issues. According to my understanding, you are popping the view controller and then coming back to it. when the controller is popped, all of the associated view are cleared and deallocated. Now in your case, this happens within the span of 5 sec. So when the timer hits, it cannot find that label(which is already deallocated).
So either you can use nstimer and invalidate it as soon as the screen goes away and hide/unhide the label when the next time screen appears depending upon the check mark state.
Please let me know if this helps.

iOS Switch statement not working?

I've got a View Controller with five buttons. Each button should trigger a modal segue to a different view controller based on the tag of the button, represented by declared constants:
- (IBAction)aButtonTapped:(UIButton *)sender
{
[self buttonForSegue:sender];
}
-(void) buttonForSegue:(UIButton *)sender
{
switch ([sender tag])
{
case aVsAButton_tag:
[self performSegueWithIdentifier:#"aVsAModal" sender:self];
break;
case cVsCButton_tag:
[self performSegueWithIdentifier:#"cVsCModal" sender:self];
break;
case actVsAllButton_tag:
[self performSegueWithIdentifier:#"actVsAllModal" sender:self];
break;
case catVsAllButton_tag:
[self performSegueWithIdentifier:#"catVsAllModal" sender:self];
break;
case customDatePickerButton_tag:
[self performSegueWithIdentifier:#"customDatePickerModal" sender:self];
break;
default:
break;
}
}
Regardless of which button I hit, the app crashes in the sim with this message (only the button names change):
2014-02-10 19:11:47.305 WMDGx[24366:a0b] -[ReportViewController aVsAllButton:]: unrecognized selector sent to instance 0x8a911e0
2014-02-10 19:11:47.307 WMDGx[24366:a0b] * ** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ReportViewController aVsAllButton:]: unrecognized selector sent to instance 0x8a911e0'
My code looks reasonable to me, but apparently not. Can someone please tell me where I'm going wrong?
Thanks!
The error you're reporting would not be caused by the code you posted. I'm guessing that you have an IBAction link in your buttons and that action method no longer exists. Open your storyboard file, select the scene for your view controller, and use the connections inspector to check the action link for each button. You may need to break the connection and re-link it to the proper IBAction.
Looks like this has nothing to do with your switch statement, but rather calling a function that doesn't exist on one of your controllers.
Which line of code does it fail on? Entering the buttonForSegue? At the start of the switch? during one of the performSegueWithIdentifier?
Things you can try:
Ensure that sender is actually a UIButton class
Ensure that the tag is set on the button
Check the view controller that you are seguing to implements the method aVsAllButton

Custom uitablecellview internal inconsistency exception

So I'm getting this error -
*** Assertion failure in void _UIPerformResizeOfTextViewForTextContainer(NSLayoutManager *, UIView<NSTextContainerView> *, NSTextContainer *, NSUInteger)(), /SourceCache/UIFoundation_Sim/UIFoundation-258.1/UIFoundation/TextSystem/NSLayoutManager_Private.m:1510
2014-01-13 18:58:55.829 ReviewApp[1678:3c03] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only run on the main thread!'
*** First throw call stack:
The error is apparent..but I'm not sure why it's happening. This is how I'm registering the nib -
UINib* dqNib = [UINib nibWithNibName:#"DQCardView" bundle:nil];
UINib* simpleListNib = [UINib nibWithNibName:#"SimpleListCell" bundle:nil];
UINib* photoPostNib = [UINib nibWithNibName:#"PhotoPostCell" bundle:nil];
[self.listView registerNib:dqNib forCellReuseIdentifier:DQCellIdentifier];
[self.listView registerNib:simpleListNib forCellReuseIdentifier:SimpleListCellIdentifier];
[self.listView registerNib: photoPostNib forCellReuseIdentifier:ListPhotoPostIdentifier];
in my cellForRowAtIndexPath, I'm doing this(my code is fairly long so I've summarize) -
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
DQCell* dqCell;
SimpleListCell* listCell;
PhotoPostCell* photoCell;
if(condition1){
listCell = [self.listView dequeueReusableCellWithIdentifier:SimpleListCellIdentifier];
//do other stuff
return listCell;
} else {
dQcell = [self.listView dequeueReusableCellWithIdentifier: DQCellIdentifier];
//do other stuff
return dQcell;
}
}
The listCell line gives me the exception..but the Dqcell line does not.
Further, in the listCell implementation I don't seem to be resizing the textView anywhere.
So what's going on? What should I be checking?
Based on the error you are getting "'NSInternalInconsistencyException', reason: 'Only run on the main thread!'", I would guess that somewhere in your code regarding a UITextView resize, you're doing something from a background thread?
Any time I'm ever doing something on a background thread, such as sending an HTTP request to a server asynchronously, and I want to display something whilst inside this background thread, such as pop up with an alertView with an error, I wrap that code in the following:
dispatch_sync(dispatch_get_main_queue(), ^{
});
This basically tells the OS to do whatever is in that block on the main thread. In the case where I pop up with an alert view while on a background thread, and when I've forgotten to do the above, the app basically locks for some period of time, seemingly broken, and randomly at a later time typically 6 or 7 seconds later, the alert pops up on screen and the app is usable again. Simple rule of thumb: don't do ANYTHING UI related on a background thread.
In your case, without looking at the entire project I wouldn't know exactly what is causing the issue. Hopefully I've given you enough information to help!

performSelector:withObject:afterDelay: not working on modal view controller

I have a modal view controller that appears, checks a service on the Internet and then dismisses itself when done. The nib contains an activity indicator and a label to inform the user what is going on.
When the update is complete, the label changes to "Update Complete" and then dismisses the view controller. However, I want it to delay the dismiss for a couple of seconds to give the user a chance to see the text before it disappears. So I've done this:
#pragma mark - AssetLoaderServiceDelegate
- (void)assetLoaderServiceDidFinishLoading:(AssetLoaderService *)service
{
[self.spinner stopAnimating];
self.infoLabel.text = #"Update complete";
[self performSelector:#selector(dismissUpdater) withObject:nil afterDelay:2.0];
}
- (void)dismissUpdater
{
[self dismissModalViewControllerAnimated:YES];
}
But for some reason, the selector is never being called. I've tried running it in mode NSRunLoopCommonModes too, but that doesn't work either.
I must be doing something wrong, but I can't see what...
EDIT: The delegate callback is actually happening within an NSOperationQueue, which might mean it's not on the same thread when it sends the message back to the view controller? So I tried
[self performSelector:#selector(downloadQueueComplete) withObject:nil afterDelay:0.0 inModes:[NSArray arrayWithObject:NSRunLoopCommonModes]];
followed by
- (void)downloadQueueComplete
{
[delegate assetLoaderServiceDidFinishLoading:self];
}
But the performSelector doesn't seem to be working here either.
Following up your suggestion about the thread issue, would you try with:
[self performSelectorOnMainThread:#selector(downloadQueueComplete) withObject:nil waitUntilDone:YES]];
Sorted! In the AssetLoaderService, I had to perform selector on main thread:
[self performSelectorOnMainThread:#selector(downloadQueueComplete) withObject:nil waitUntilDone:YES];
After that, all the following calls were on the correct thread. :)

performSegueWithIdentifier crashes randomly

I have never had this problem before or heard of it happening. I am using a Master-Detail Application (splitview) for the ipad. I have a dynamic tableview for my MVC and am trying to transition each cell to a custom view controller.
Currently I only have two items in my table. When the program boots I can select either of them and it will transition to the correct view controller without any problems. But most of the time when I click on something a second time the program crashes. Sometimes it takes four or five clicks but it always eventually crashes.
Here is the code snippet:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *segueName = [self.tableObjects objectAtIndex:indexPath.row];
[self performSegueWithIdentifier:segueName sender:self];
}
tableObjects is an NSArray that I use to create the table items. If I throw a print statement in before the segue call it does print the correct segue name.
The error is always being thrown on the actual performSegueWithIdentifier call. I checked it with the debugger. The exception I keep getting is: EXC_BAD_ACCESS.
Again both of the segues work initially so I do not think it is a problem with this. Does this method sometimes get called randomly? Is there a way to double check that the method call is safe? Do I need to override performSegueWithIdentifier and do something there?
I attempted to put it into a try catch:
#try {
[self performSegueWithIdentifier:segueName sender:self];
}
#catch (NSException *exception) {
NSLog(#"%#", exception);
}
#finally {
NSLog(#"finally");
}
and it still pointed to the method call inside of the #try. It does not seem to be throwing the error like an exception?
FYI, I was running into this exact same issue, and I found the answer on another SO thread: iOS - UISplitViewController with storyboard - multiple master views and multiple detail views
Basically, the uisplitviewcontroller delegate needed to be set again when making the segue. Hope this helps someone in the future.

Resources