I have a UITabBarController with three views. When I select View#2 the application crashes (see crash log). If I reorder the tabs so that View#2 is first it works (No crash).
0 libobjc.A.dylib 0x3368ef78 objc_msgSend + 16
1 CoreFoundation 0x359b8e90 CFRetain + 76
2 CoreFoundation 0x359c2b74 +[__NSArrayI __new::] + 48
3 CoreFoundation 0x359c2a8e -[__NSPlaceholderArray initWithObjects:count:] + 294
4 CoreFoundation 0x359c27ce +[NSArray arrayWithObjects:count:] + 38
5 CoreFoundation 0x359c24f2 -[NSDictionary allValues] + 230
6 UIKit 0x333e7f46 -[UINib instantiateWithOwner:options:] + 538
7 UIKit 0x333563c0 -[UIViewController _loadViewFromNibNamed:bundle:] + 240
8 UIKit 0x33233c52 -[UIViewController loadView] + 82
9 UIKit 0x331a9c10 -[UIViewController view] + 44
10 UIKit 0x33209636 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 86
11 UIKit 0x332095d4 -[UITabBarController transitionFromViewController:toViewController:] + 24
12 UIKit 0x33208f0e -[UITabBarController _setSelectedViewController:] + 294
13 UIKit 0x3329244e -[UITabBarController _tabBarItemClicked:] + 338
14 CoreFoundation 0x359ca3f6 -[NSObject performSelector:withObject:withObject:] + 46
15 UIKit 0x3318be00 -[UIApplication sendAction:to:from:forEvent:] + 56
16 UIKit 0x3318bdbc -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 24
17 UIKit 0x332922d2 -[UITabBar _sendAction:withEvent:] + 346
18 CoreFoundation 0x359ca3f6 -[NSObject performSelector:withObject:withObject:] + 46
19 UIKit 0x3318be00 -[UIApplication sendAction:to:from:forEvent:] + 56
20 UIKit 0x3318bdbc -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 24
21 UIKit 0x3318bd9a -[UIControl sendAction:to:forEvent:] + 38
22 UIKit 0x3318bb0a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 486
23 UIKit 0x33292062 -[UITabBar(Static) _buttonUp:] + 110
24 CoreFoundation 0x359ca3f6 -[NSObject performSelector:withObject:withObject:] + 46
25 UIKit 0x3318be00 -[UIApplication sendAction:to:from:forEvent:] + 56
26 UIKit 0x3318bdbc -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 24
27 UIKit 0x3318bd9a -[UIControl sendAction:to:forEvent:] + 38
28 UIKit 0x3318bb0a -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 486
29 UIKit 0x3318c442 -[UIControl touchesEnded:withEvent:] + 470
30 UIKit 0x3318a924 -[UIWindow _sendTouchesForEvent:] + 312
31 UIKit 0x3318a312 -[UIWindow sendEvent:] + 374
32 UIKit 0x3317068e -[UIApplication sendEvent:] + 350
33 UIKit 0x3316ff34 _UIApplicationHandleEvent + 5820
34 GraphicsServices 0x33762224 PurpleEventCallback + 876
35 CoreFoundation 0x35a4451c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
36 CoreFoundation 0x35a444be __CFRunLoopDoSource1 + 134
37 CoreFoundation 0x35a4330c __CFRunLoopRun + 1364
38 CoreFoundation 0x359c649e CFRunLoopRunSpecific + 294
39 CoreFoundation 0x359c6366 CFRunLoopRunInMode + 98
40 GraphicsServices 0x33761432 GSEventRunModal + 130
41 UIKit 0x3319ecce UIApplicationMain + 1074
42 TecNotes 0x000c2a28 main (main.m:18)
43 TecNotes 0x000c2940 start + 32
There is no custom class or instance initialization. And the viewDidLoad method of View#2 does not seem to execute.
In an effort to debug the issue the viewDidLoad for View#2 has been reduced to the following.
- (void)viewDidLoad
{
NSLog(#"Enter View#2 viewDidLoad");
[super viewDidLoad];
NSLog(#"Exit View#2 viewDidLoad");
}
View#1 has similar logging to record that the viewDidLoad method is called.
- (void)viewDidLoad
{
NSLog(#"Enter View#1 viewDidLoad");
[super viewDidLoad];
NSFileManager *filemgr = [NSFileManager defaultManager];
NSString *cd = [filemgr currentDirectoryPath];
recipeName = [cd lastPathComponent];
NSString *basedir = [CategoryViewController getBaseDir];
int startPos = [basedir length]+1;
int len = [cd length]-startPos;
NSString *tmp = [cd substringWithRange:NSMakeRange(startPos, len)];
title = [CategoryViewController decode:tmp];
//self.navigationItem.backBarButtonItem.title = recipeName;
//self.tabBarController.navigationItem.title = recipeName;
currentNote = 0;
//-------
UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:#selector(swipedScreen:)];
swipeGesture.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeGesture];
swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:#selector(swipedScreen:)];
swipeGesture.direction = UISwipeGestureRecognizerDirectionLeft ;
[self.view addGestureRecognizer:swipeGesture];
//-------
UIBarButtonItem *back = [[UIBarButtonItem alloc] initWithTitle:#"Menu" style:UIBarButtonItemStylePlain target:self action:#selector(backButtonPressed)];
self.navigationItem.backBarButtonItem = back;
self.tabBarController.navigationItem.backBarButtonItem = back;
[noteView setFont:[UIFont systemFontOfSize:[NotesViewController getFontSize]]];
[self loadNotes];
NSLog(#"Exit View#1 viewDidLoad");
}
Here is the resulting log entries.
Dec 16 11:42:21 Tonys-iPad TecNotes[6577] : Enter View#1 viewDidLoad
Dec 16 11:42:21 Tonys-iPad TecNotes[6577] : Exit View#1 viewDidLoad
Dec 16 11:42:27 Tonys-iPad ReportCrash[6580] : Formulating crash report for process TecNotes[6577]
Dec 16 11:42:27 Tonys-iPad com.apple.launchd[1] (UIKitApplication:com.bringardner.tecnotes[0x2bd8][6577]) : (UIKitApplication:com.bringardner.tecnotes[0x2bd8]) Job appears to have crashed: Segmentation fault: 11
Related
I am a newbie who is learning OC.
But now when I set an outlet button as a property of my viewcontroller, in order to add an attribute for it, when I write some methods in viewDidLoad, something wrong happened like this:
The only thing I want to do is to set the attributes of the outLetButton.currentTitle
And my code is as follows:
There is nothing wrong with my button.
(void)viewDidLoad {
[super viewDidLoad];
/
NSMutableAttributedString * title = [[NSMutableString alloc] initWithString:self.OutletButton.currentTitle] ;
[title setAttributes:#{NSStrokeWidthAttributeName:#3.0,NSStrokeColorAttributeName:[self.OutletButton tintColor]} range:NSMakeRange(0, [title length])] ;
[self.OutletButton setAttributedTitle:title forState:UIControlStateNormal] ;
}
I used breakout debugging, when I step over [title setAttributes...], it crashed.
First throw call stack
0 CoreFoundation 0x000000010ba0b12b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010b09ff41 objc_exception_throw + 48
2 CoreFoundation 0x000000010ba8c024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010b98df78 forwarding + 1432
4 CoreFoundation 0x000000010b98d958 _CF_forwarding_prep_0 + 120
5 UITextView 0x000000010a791106 -[ViewController viewDidLoad] + 598
6 UIKit 0x000000010c03146c -[UIViewController loadViewIfRequired] + 1235
7 UIKit 0x000000010c0318b9 -[UIViewController view] + 27
8 UIKit 0x000000010befc7cf -[UIWindow addRootViewControllerViewIfPossible] + 122
9 UIKit 0x000000010befced7 -[UIWindow _setHidden:forced:] + 294
10 UIKit 0x000000010bf0fe54 -[UIWindow makeKeyAndVisible] + 42
11 UIKit 0x000000010be828b8 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4737
12 UIKit 0x000000010be87aeb -[UIApplication _runWithMainScene:transitionContext:completion:] + 1720
13 UIKit 0x000000010c2516f8 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 924
14 UIKit 0x000000010c6274c8 +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
15 UIKit 0x000000010c2512f1 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 249
16 UIKit 0x000000010c251b6b -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 696
17 UIKit 0x000000010cbcfa69 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 262
18 UIKit 0x000000010cbcf922 -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 444
19 UIKit 0x000000010c8ac9c8 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 221
20 UIKit 0x000000010caabb06 _performActionsWithDelayForTransitionContext + 100
21 UIKit 0x000000010c8ac88b -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 231
22 UIKit 0x000000010c626b25 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
23 UIKit 0x000000010be8636a -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 523
24 UIKit 0x000000010c461605 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 369
25 FrontBoardServices 0x0000000110158cc0 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 338
26 FrontBoardServices 0x00000001101617b5 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 235
27 libdispatch.dylib 0x000000010f3b733d _dispatch_client_callout + 8
28 libdispatch.dylib 0x000000010f3bc9f3 _dispatch_block_invoke_direct + 592
29 FrontBoardServices 0x000000011018d498 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 24
30 FrontBoardServices 0x000000011018d14e -[FBSSerialQueue _performNext] + 464
31 FrontBoardServices 0x000000011018d6bd -[FBSSerialQueue _performNextFromRunLoopSource] + 45
32 CoreFoundation 0x000000010b9ae101 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
33 CoreFoundation 0x000000010ba4df71 __CFRunLoopDoSource0 + 81
34 CoreFoundation 0x000000010b992a19 __CFRunLoopDoSources0 + 185
35 CoreFoundation 0x000000010b991fff __CFRunLoopRun + 1279
36 CoreFoundation 0x000000010b991889 CFRunLoopRunSpecific + 409
37 GraphicsServices 0x0000000110a219c6 GSEventRunModal + 62
38 UIKit 0x000000010be895d6 UIApplicationMain + 159
39 UITextView 0x000000010a7914df main + 111
40 libdyld.dylib 0x000000010f433d81 start + 1
41 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
The issue is because you are initialising NSMutableAttributedString with NSMutableString & then changes its attribute..
The code lets you initialise the variable But NSMutableString doesn't allow you to add attributes so it crashes..
The code should be like this.. (change allocation class to NSMutableAttributedString)
NSMutableAttributedString * title = [[NSMutableAttributedString alloc] initWithString:self.OutletButton.currentTitle] ;
[title setAttributes:#{NSStrokeWidthAttributeName:#3.0,NSStrokeColorAttributeName:[self.OutletButton tintColor]} range:NSMakeRange(0, [title length])] ;
[self.OutletButton setAttributedTitle:title forState:UIControlStateNormal] ;
Thanks.
I am trying to set up a UITableView inside of a UIViewController. I am using storyboard. but when running it on the simulator, the tableview does not display. Here is the simple view in Xcode:
#implementation ForthViewController{
NSArray *menuItems;
}
- (void)viewDidLoad {
[super viewDidLoad];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSArray *o = [prefs mutableArrayValueForKey:#"option"];
NSLog(#"%#",o);
menuItems =[NSArray arrayWithArray:o];
[self viewrequest];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [menuItems count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *simpleTableIdentifier = #"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [menuItems objectAtIndex:indexPath.row];
return cell;
}
I am getting following error:
2016-11-29 11:57:44.987 Wellness_24x7[1400:46606] -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x7a67d160
2016-11-29 11:57:45.010 Wellness_24x7[1400:46606] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x7a67d160'
*** First throw call stack:
(
0 CoreFoundation 0x00b4da14 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0060ee02 objc_exception_throw + 50
2 CoreFoundation 0x00b56d63 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x00a946bd ___forwarding___ + 1037
4 CoreFoundation 0x00a9428e _CF_forwarding_prep_0 + 14
5 UIKit 0x01884c1c -[UITableViewLabel setText:] + 120
6 Wellness_24x7 0x000f16c4 -[ForthViewController tableView:cellForRowAtIndexPath:] + 372
7 UIKit 0x014df398 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 822
8 UIKit 0x014df4e1 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 90
9 UIKit 0x014af948 -[UITableView _updateVisibleCellsNow:isRecursive:] + 3347
10 UIKit 0x014ce0d6 __29-[UITableView layoutSubviews]_block_invoke + 52
11 UIKit 0x014e919e -[UITableView _performWithCachedTraitCollection:] + 88
12 UIKit 0x014cdfab -[UITableView layoutSubviews] + 214
13 UIKit 0x01424008 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810
14 libobjc.A.dylib 0x00623059 -[NSObject performSelector:withObject:] + 70
15 QuartzCore 0x0569280a -[CALayer layoutSublayers] + 144
16 QuartzCore 0x056864ee _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
17 QuartzCore 0x05694d2a -[CALayer(CALayerPrivate) layoutBelowIfNeeded] + 44
18 UIKit 0x014117c0 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1258
19 UIKit 0x014112c2 -[UIView(Hierarchy) layoutIfNeeded] + 82
20 UIKit 0x01585420 -[UITabBarController _layoutViewController:] + 845
21 UIKit 0x0158557a -[UITabBarController _wrapperViewForViewController:] + 262
22 UIKit 0x01591ba6 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 787
23 UIKit 0x01590a0e -[UITabBarController transitionFromViewController:toViewController:] + 76
24 UIKit 0x0158c0dd -[UITabBarController _setSelectedViewController:] + 453
25 UIKit 0x0158bee4 -[UITabBarController setSelectedViewController:] + 252
26 UIKit 0x01590839 -[UITabBarController _tabBarItemClicked:] + 587
27 libobjc.A.dylib 0x006230b5 -[NSObject performSelector:withObject:withObject:] + 84
28 UIKit 0x01359b79 -[UIApplication sendAction:to:from:forEvent:] + 118
29 UIKit 0x01359af8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
30 UIKit 0x017a70fb -[UITabBar _sendAction:withEvent:] + 525
31 libobjc.A.dylib 0x006230b5 -[NSObject performSelector:withObject:withObject:] + 84
32 UIKit 0x01359b79 -[UIApplication sendAction:to:from:forEvent:] + 118
33 UIKit 0x01359af8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
34 UIKit 0x014f98f8 -[UIControl sendAction:to:forEvent:] + 79
35 UIKit 0x014f9c78 -[UIControl _sendActionsForEvents:withEvent:] + 408
36 UIKit 0x014f9938 -[UIControl sendActionsForControlEvents:] + 48
37 UIKit 0x017ace41 -[UITabBar(Static) _buttonUp:] + 123
38 libobjc.A.dylib 0x006230b5 -[NSObject performSelector:withObject:withObject:] + 84
39 UIKit 0x01359b79 -[UIApplication sendAction:to:from:forEvent:] + 118
40 UIKit 0x01359af8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
41 UIKit 0x014f98f8 -[UIControl sendAction:to:forEvent:] + 79
42 UIKit 0x014f9c78 -[UIControl _sendActionsForEvents:withEvent:] + 408
43 UIKit 0x014f8c7e -[UIControl touchesEnded:withEvent:] + 714
44 UIKit 0x013d6182 -[UIWindow _sendTouchesForEvent:] + 1095
45 UIKit 0x013d7220 -[UIWindow sendEvent:] + 1159
46 UIKit 0x0137bf93 -[UIApplication sendEvent:] + 266
47 UIKit 0x01351668 _UIApplicationHandleEventQueue + 7802
48 CoreFoundation 0x00a676ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
49 CoreFoundation 0x00a5d38b __CFRunLoopDoSources0 + 523
50 CoreFoundation 0x00a5c7a8 __CFRunLoopRun + 1032
51 CoreFoundation 0x00a5c0e6 CFRunLoopRunSpecific + 470
52 CoreFoundation 0x00a5befb CFRunLoopRunInMode + 123
53 GraphicsServices 0x05133664 GSEventRunModal + 192
54 GraphicsServices 0x051334a1 GSEventRun + 104
55 UIKit 0x01357bfa UIApplicationMain + 160
56 Wellness_24x7 0x000cba6a main + 138
57 libdyld.dylib 0x033c6a21 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Change this line
cell.textLabel.text = [menuItems objectAtIndex:indexPath.row];
with this
cell.textLabel.text = [NSString stringWithFormat:#"%#",[menuItems objectAtIndex:indexPath.row]];
Problem - The reason of the crash is cell.textLabel.text is expecting a NSString value and you are passing NSCFNumber in it so you need to convert NSCFNumber to NSString
I have an old code, without ARC, without Autolayout and I am constructing theUITableViewCell programmatically. TheUITableViewCell contains aUITextView. The cell is constructed properly but when I tap on theUITextView for editing the app freezes and after some time it exists (I think it's because it's taking a lot of CPU Time). This only happens with iOS 8, other versions it works fine.
I debugged and I do getUIKeyboardWillShowNotification notification but the keyboard does not show up and I can't do anything after this.
Below is the code
// Register notification when the keyboard will be show
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
// Register notification when the keyboard will be hide
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
CGRect frame = CGRectMake(MIN_X,(LABEL_HEIGHT + VERTICAL_PADDING) + 2,TEXT_BOX_WIDTH,TEXT_BOX_HEIGHT);
self.roundRectView = [[RoundRectView alloc]initWithFrame:frame];
self.roundRectView.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:roundRectView];
inputTextView = [[UITextView alloc] initWithFrame:frame];
inputTextView.editable = YES;
inputTextView.delegate = self;
if(self.parameter.selectedValue == nil || [self.parameter.selectedValue length] == 0){
inputTextView.text = self.parameter.label;
}
else{
inputTextView.text = self.parameter.selectedValue;
}
inputTextView.backgroundColor = [UIColor clearColor];
inputTextView.textAlignment = UITextAlignmentLeft;
inputTextView.font = [UIFont fontWithName:#"HelveticaNeue" size:15.0];
inputTextView.textColor = [UIColor grayColor];
inputTextView.scrollEnabled = NO;
inputTextView.bounces = NO;
inputTextView.autocorrectionType = UITextAutocorrectionTypeNo;
[self.contentView addSubview:inputTextView];
Below is theUIKeyboardWillShowNotification handler :-
-(void) keyboardWillShow:(NSNotification *)note{
if([self.inputTextView isFirstResponder]) {
// Get the keyboard size
CGRect keyboardBounds;
[[note.userInfo valueForKey:UIKeyboardFrameBeginUserInfoKey] getValue: &keyboardBounds];
// Detect orientation
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
CGRect frame = self.parentTableView.frame;
// Start animation
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.3f];
// Reduce size of the Table view
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
frame.size.height -= keyboardBounds.size.height-100;
else
frame.size.height -= keyboardBounds.size.width-100;
// Apply new size of table view
self.parentTableView.frame = frame;
// Scroll the table view to see the TextField just above the keyboard
if (self.inputTextView)
{
CGRect textFieldRect = [self.parentTableView convertRect:self.inputTextView.bounds fromView:self.inputTextView];
[self.parentTableView scrollRectToVisible:textFieldRect animated:NO];
}
[UIView commitAnimations];
}}
Below is the crash report. My app name is "My App"
Exception Type: 00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread: 0
Application Specific Information:
com.myapp.app failed to exit in time
Elapsed total CPU time (seconds): 8.070 (user 8.070, system 0.000), 66% CPU
Elapsed application CPU time (seconds): 5.689, 47% CPU
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 QuartzCore 0x27e013ca x_hash_table_lookup + 62
1 QuartzCore 0x27e10c60 CAMediaTimingCopyRenderTiming + 120
2 QuartzCore 0x27e0fd4a CA::Layer::add_animation(CAAnimation*, __CFString const*) + 650
3 QuartzCore 0x27e0f876 -[CALayer addAnimation:forKey:] + 478
4 UIKit 0x28673c4c __67-[_UIViewAdditiveAnimationAction runActionForKey:object:arguments:]_block_invoke + 376
5 UIKit 0x28673a98 -[_UIViewAdditiveAnimationAction runActionForKey:object:arguments:] + 544
6 QuartzCore 0x27e02788 CA::Layer::end_change(CA::Transaction*, unsigned int, objc_object*) + 92
7 QuartzCore 0x27e03322 CA::Layer::set_bounds(CA::Rect const&, bool) + 522
8 QuartzCore 0x27e03046 -[CALayer setBounds:] + 106
9 QuartzCore 0x27e0407a -[CALayer setFrame:] + 538
10 UIKit 0x283dcfde -[UIView(Geometry) setFrame:] + 250
11 UIKit 0x283f7408 -[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] + 804
12 UIKit 0x283f70d2 -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 254
13 CoreFoundation 0x24e6506e __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 86
14 CoreFoundation 0x24e64f68 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 200
15 UIKit 0x283e7bea -[UIView(Geometry) resizeSubviewsWithOldSize:] + 114
16 UIKit 0x283dd0f2 -[UIView(Geometry) setFrame:] + 526
17 UIKit 0x28469320 -[UILayoutContainerView setFrame:] + 56
18 UIKit 0x283f7408 -[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:] + 804
19 UIKit 0x283f70d2 -[UIView(Geometry) _resizeWithOldSuperviewSize:] + 254
20 CoreFoundation 0x24e6506e __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 86
21 CoreFoundation 0x24e64f68 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 200
22 UIKit 0x283e7bea -[UIView(Geometry) resizeSubviewsWithOldSize:] + 114
23 UIKit 0x28429b40 -[UIView(Geometry) setBounds:] + 476
24 UIKit 0x288b7ad8 -[UIDropShadowView setBounds:] + 124
25 UIKit 0x287cdf84 -[_UIFormSheetPresentationController containerViewWillLayoutSubviews] + 272
26 UIKit 0x283e0154 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 440
27 QuartzCore 0x27e0bf60 -[CALayer layoutSublayers] + 132
28 QuartzCore 0x27e0794c CA::Layer::layout_if_needed(CA::Transaction*) + 356
29 UIKit 0x283f28e6 -[UIView(Hierarchy) layoutBelowIfNeeded] + 134
30 UIKit 0x28413d22 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 474
31 UIKit 0x28413b3e +[UIView(UIViewAnimationWithBlocks) animateWithDuration:animations:] + 62
32 UIKit 0x287cdb44 -[_UIFormSheetPresentationController _changeLayoutModeToAvoidKeyboard:] + 220
33 CoreFoundation 0x24ef6f12 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 10
34 CoreFoundation 0x24e51e48 _CFXNotificationPost + 1796
35 Foundation 0x25b86e5c -[NSNotificationCenter postNotificationName:object:userInfo:] + 72
36 UIKit 0x28a44b94 -[UIInputWindowController postStartNotifications:withInfo:] + 412
37 UIKit 0x28a45fb4 __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke579 + 396
38 UIKit 0x28413d22 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 474
39 UIKit 0x284d579e +[UIView(UIViewAnimationWithBlocks) _animateWithDuration:delay:options:animations:start:completion:] + 62
40 UIKit 0x284a093a -[UIInputViewAnimationStyle launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:] + 166
41 UIKit 0x28a45d18 -[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:] + 828
42 UIKit 0x28a49584 -[UIInputWindowController setPlacement:starting:completion:] + 44
43 UIKit 0x28a4913a -[UIInputWindowController setInputViewSet:] + 610
44 UIKit 0x28a457aa -[UIInputWindowController performOperations:withAnimationStyle:] + 38
45 UIKit 0x28498102 -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 1010
46 UIKit 0x2845b7f0 -[UIResponder becomeFirstResponder] + 404
47 UIKit 0x2845bab6 -[UIView(Hierarchy) becomeFirstResponder] + 102
48 UIKit 0x2857ab6a -[UITextView becomeFirstResponder] + 70
49 UIKit 0x2857aa6a -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 170
50 UIKit 0x2857a36a -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 1994
51 UIKit 0x285601aa _UIGestureRecognizerSendActions + 290
52 UIKit 0x2840ec98 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 664
53 UIKit 0x28823a8c ___UIGestureRecognizerUpdate_block_invoke661 + 44
54 UIKit 0x283d8512 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 214
55 UIKit 0x283d648a _UIGestureRecognizerUpdate + 2946
56 UIKit 0x2840d088 -[UIWindow _sendGesturesForEvent:] + 780
57 UIKit 0x2840c958 -[UIWindow sendEvent:] + 516
58 UIKit 0x283e30e0 -[UIApplication sendEvent:] + 192
59 My App 0x0023e95a 0x28000 + 2189658
60 UIKit 0x28656b9e _UIApplicationHandleEventFromQueueEvent + 13870
61 UIKit 0x283e1b22 _UIApplicationHandleEventQueue + 1290
62 CoreFoundation 0x24f04fd4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 12
63 CoreFoundation 0x24f043e6 __CFRunLoopDoSources0 + 218
64 CoreFoundation 0x24f02a64 __CFRunLoopRun + 764
65 CoreFoundation 0x24e4fb2c CFRunLoopRunSpecific + 472
66 CoreFoundation 0x24e4f93e CFRunLoopRunInMode + 102
67 GraphicsServices 0x2c1d504c GSEventRunModal + 132
68 UIKit 0x28441f1c UIApplicationMain + 1436
69 My App 0x0002e56e 0x28000 + 25966
70 My App 0x0002e4f4 0x28000 + 25844
Posting my solution if anyone faces same issue.
The TextView was in an view controller which was presented modally using UIModalPresentationFormSheet presentation style. After I changed to UIModalPresentationPageSheet it worked fine. This means the Form sheet caused some problem while popping up the keyboard.
I have a UIViewController:DFUserChatViewController witch is inherit form DFChatViewController,in DFChatViewController init method I have a navigationItem.leftBarButtonItem with a method backAction
- (id)init
{
self = [super init];
if (self)
{
...........
self.navigationItem.leftBarButtonItem = [[[DFBarBackButtonItem alloc] initWithTarget:self action:#selector(backAction:) image:nil] autorelease];
}
return self;
}
in DFUserChatViewController I overwrite the method backAction:
#pragma mark - action
-(void)backAction:(id)sender
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
.............any other thing
.............
{
[self.navigationController popViewControllerAnimated:YES];
}
}
I use crashlytics for crash report and today I receive a crash
0
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x4000000c
raw
0
libobjc.A.dylib objc_msgSend + 5
1
DFmyPro
DFUserChatViewController.m line 349
-[DFUserChatViewController backAction:]
2
UIKit -[UIApplication sendAction:to:from:forEvent:] + 90
3
UIKit -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30
4
UIKit -[UIControl sendAction:to:forEvent:] + 44
5
UIKit -[UIControl _sendActionsForEvents:withEvent:] + 374
6
UIKit -[UIControl touchesEnded:withEvent:] + 590
7
UIKit -[UIWindow _sendTouchesForEvent:] + 528
8
UIKit -[UIWindow sendEvent:] + 832
9
DFmyPro
DFShakeWindow.m line 46
-[DFShakeWindow sendEvent:]
10
UIKit -[UIApplication sendEvent:] + 196
11
UIKit _UIApplicationHandleEventQueue + 7098
12 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
13
CoreFoundation __CFRunLoopDoSources0 + 206
14
CoreFoundation __CFRunLoopRun + 622
15
CoreFoundation CFRunLoopRunSpecific + 522
16
CoreFoundation CFRunLoopRunInMode + 106
17
GraphicsServices GSEventRunModal + 138
18 UIKit UIApplicationMain + 1136
19
DFmyPro
main.m line 15
main
I run my app again and again ,and didn‘t catch the crash ,How do I know where goes wrong
I have an App written for iOS 6 that uses UICollectionViewController, the app works fine but when I tried to compile in Xcode 5 I get the error bellow.
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'layout cannot be nil in setCollectionViewLayout:'...
I tried to use this solution but I keep getting the same error. Any ideas?
CollectionViewLayout *layout = [[CollectionViewLayout alloc] init];
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
[self.collectionView registerClass:[Cell class] forCellWithReuseIdentifier:ItemIdentifier];
[self.collectionView registerClass:[HeaderCollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:#"HeaderView"];
self.collectionLayout.headerReferenceSize = CGSizeMake(0, 50);
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
self.collectionView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
self.collectionLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
//Stack trace
2013-10-01 14:15:37.140 MemberCatalog[10841:a0b] *** Assertion failure in -[UICollectionView setCollectionViewLayout:], /SourceCache/UIKit_Sim/UIKit-2903.2/UICollectionView.m:2001
2013-10-01 14:15:37.186 MemberCatalog[10841:a0b] Uncaught exception: NSInternalInconsistencyException
Reason: layout cannot be nil in setCollectionViewLayout:
User Info: (null)
Call Stack: (
0 CoreFoundation 0x031e75e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x02c548b6 objc_exception_throw + 44
2 CoreFoundation 0x031e7448 +[NSException raise:format:arguments:] + 136
3 Foundation 0x0029923e -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x00cdeba3 -[UICollectionView setCollectionViewLayout:] + 156
5 UIKit 0x00cfcd7b -[UICollectionViewControllerWrapperView didMoveToSuperview] + 462
6 UIKit 0x007261a6 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 472
7 UIKit 0x00725ef8 -[UIView(Hierarchy) _postMovedFromSuperview:] + 260
8 UIKit 0x00731031 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1847
9 UIKit 0x00724521 -[UIView(Hierarchy) addSubview:] + 56
10 UIKit 0x007d66eb +[UIViewControllerWrapperView wrapperViewForView:wrapperFrame:viewFrame:] + 382
11 UIKit 0x0080c867 -[UITabBarController _wrapperViewForViewController:] + 221
12 UIKit 0x00813a60 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 441
13 UIKit 0x00813262 -[UITabBarController transitionFromViewController:toViewController:] + 63
14 UIKit 0x0080f64b -[UITabBarController _setSelectedViewController:] + 279
15 UIKit 0x0080f470 -[UITabBarController setSelectedIndex:] + 261
16 MemberCatalog 0x000aa9f8 -[MainViewController updateTabBar:] + 584
17 MemberCatalog 0x000ab872 -[MainViewController showCategory::] + 3538
18 MemberCatalog 0x000abe30 -[MainViewController menuButtonTap:] + 1296
19 libobjc.A.dylib 0x02c66874 -[NSObject performSelector:withObject:withObject:] + 77
20 UIKit 0x006cac8c -[UIApplication sendAction:to:from:forEvent:] + 108
21 UIKit 0x006cac18 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
22 UIKit 0x007c26d9 -[UIControl sendAction:to:forEvent:] + 66
23 UIKit 0x007c2a9c -[UIControl _sendActionsForEvents:withEvent:] + 577
24 UIKit 0x007c1d4b -[UIControl touchesEnded:withEvent:] + 641
25 UIKit 0x007080cd -[UIWindow _sendTouchesForEvent:] + 852
26 UIKit 0x00708d34 -[UIWindow sendEvent:] + 1232
27 UIKit 0x006dca36 -[UIApplication sendEvent:] + 242
28 UIKit 0x006c6d9f _UIApplicationHandleEventQueue + 11421
29 CoreFoundation 0x031708af __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
30 CoreFoundation 0x0317023b __CFRunLoopDoSources0 + 235
31 CoreFoundation 0x0318d30e __CFRunLoopRun + 910
32 CoreFoundation 0x0318cb33 CFRunLoopRunSpecific + 467
33 CoreFoundation 0x0318c94b CFRunLoopRunInMode + 123
34 GraphicsServices 0x03c6a9d7 GSEventRunModal + 192
35 GraphicsServices 0x03c6a7fe GSEventRun + 104
36 UIKit 0x006c994b UIApplicationMain + 1225
37 MemberCatalog 0x000033e6 main + 134
38 libdyld.dylib 0x0395a725 start + 0
please remove this line:
self.collectionLayout.headerReferenceSize = CGSizeMake(0, 50);
then, it should works