is happened a strange bug. In my app I have a login screen with 2 textfield, username and password.
For more legibility i would create a left space padding. Ok, I have been writed:
UIView *spacerViewuser = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
UIView *spacerViewpwd = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)];
[usertextfield setLeftViewMode:UITextFieldViewModeAlways];
[usertextfield setLeftView:spacerViewuser];
[pwdtextfield setLeftViewMode:UITextFieldViewModeAlways];
[pwdtextfield setLeftView:spacerViewpwd];
But this causes a crash of my app. The error is:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIKeyboardTaskQueue
waitUntilAllTasksAreFinished] may only be called from the main
thread.'
Any ideas?
Related
I have an Application, that takes Restaurants from shared Google Api and displays it in a table view.Then i use
Carbon-kit
for pull to refresh content of tableview
refresh = [[CarbonSwipeRefresh alloc] initWithScrollView:self.tblRest];
//[refresh setMarginTop:120];
[refresh setColors:#[[UIColor blueColor], [UIColor redColor], [UIColor orangeColor], [UIColor greenColor]]];
[self.view addSubview:refresh];
[refresh addTarget:self action:#selector(pullToRefresh:) forControlEvents:UIControlEventValueChanged];
When i scroll my table and try to refresh it, It gives me below error:-
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds for empty array'
please help me for this error.
Thanking you in advance.
This is happening because you must be initializing your array again while refreshing.
I am using this link here to change the font and color of title in navigation bar. I also tried this. Both of them run fine in ios8 but when i test in ios7 each time it crashes at "NSFontAttributeName". If i remove the code to set the font and only set the color , it works.
The crash message that I get is * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[1]
Any help would be appreciated. Hope my problem is clear.
Use this code:
UINavigationBar *navBar = [UINavigationBar appearance];
[navBar setTitleTextAttributes:#{NSFontAttributeName: [UIFont fontWithName:#"yourFont" size:15]];
Try this, it works fine for me in both IOS8 as well as IOS7
`
NSShadow * shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor clearColor];
shadow.shadowOffset = CGSizeMake(0, 0);
[self.navigationBar setTitleTextAttributes:#{NSForegroundColorAttributeName:#"custom-color",
NSShadowAttributeName: shadow,
NSFontAttributeName: #"font-name",
}];`
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[UISlider
setPopUpViewCornerRadius:]: unrecognized selector sent to instance
0xa44bef0'
Code:
self.slider1.maximumValue = 255.0;
self.slider1.popUpViewCornerRadius = 25.0;
[self.slider1 setMaxFractionDigitsDisplayed:0];
self.slider1.popUpViewColor = [UIColor colorWithHue:0.55 saturation:0.8 brightness:0.9 alpha:0.7];
self.slider1.font = [UIFont fontWithName:#"GillSans-Bold" size:22];
self.slider1.textColor = [UIColor colorWithHue:0.55 saturation:1.0 brightness:0.5 alpha:1];
Please guide me, Thanks in Advance
UISlider doesn't have this property popUpViewCornerRadius, because of that this error is occurring. You will need to remove this below line.
self.slider1.popUpViewCornerRadius = 25.0;
When you are allocating self.slider you need to use ASValueTrackingSlider instead of UISlider.
if you are using story board or xib you need to give ASValueTrackingSlider in identity inspector. like
http://cocoadocs.org/docsets/ASValueTrackingSlider/0.9.2/Classes/ASValueTrackingSlider.html refer the link.
UiSlider does not have this property of
popUpViewCornerRadius
Either remove this line else this property would be included in the Custom class.
So change the UISlider *slider1 to ASValueTrackingSlider *slider1
I have this code:
UIGraphicsBeginImageContextWithOptions(CGSizeMake(100, 100), NO, 0);
UIFont* font = [UIFont systemFontOfSize:12.0f];
NSDictionary* attributes = #{ NSFontAttributeName: font };
[#"hello" drawInRect:CGRectMake(0, 0, 100, 100) withAttributes:attributes];
UIGraphicsEndImageContext();
It crashes in drawInRect with
-[__NSDictionaryI font]: unrecognized selector sent to instance 0xcb77be0
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI font]:
unrecognized selector sent to instance 0xcb77be0'
It works fine if I use deprecated
[#"hello" drawInRect:CGRectMake(0, 0, 100, 100) withFont:font];
What am I doing wrong?
The reason is you deployed your app on old iOS versio (<7.0) which didn't support method drawInRect:withAttributes:. Also, that's why you could run the deprecated one without problem.
I have a UIView in which i have written the following method:
- (void)drawLabels:(NSMutableArray*)labelArray{
for (int i=0; i<[labelArray count]; i++) {
CGRect labelFrame = CGRectMake(0, 0, 50, 50);
labelFrame = CGRectInset(labelFrame, 5, 5);
UILabel *label = (UILabel*)[labelArray objectAtIndex:i];
[self addSubview:label];
}
The code crashes with the following error :
-[UIDeviceRGBColor superview]: unrecognized selector sent to instance 0x6e397c0
2012-11-27 18:37:33.559 QuartzSample[57621:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIDeviceRGBColor superview]: unrecognized selector sent to instance 0x6e397c0'
* First throw call stack:
(0x13cf022 0x1560cd6 0x13d0cbd 0x1335ed0 0x1335cb2 0x55e4f 0x5014b 0x4398 0x38a1 0xe0a1e 0x3f401 0x3f670 0x3f836 0x4672a 0x292b 0x17386 0x18274 0x27183 0x27c38 0x1b634 0x12b9ef5 0x13a3195 0x1307ff2 0x13068da 0x1305d84 0x1305c9b 0x17c65 0x19626 0x2632 0x25a5)
terminate called throwing an exception(lldb)
I wish to place the labels on the view with all the formatting(color, font,size,etc.).
Also when i put the following code :
NSLog(#"%#",[labelArray objectAtIndex:i]);
i get the following in console:
UIDeviceRGBColorSpace 0 1 0 0.3
Can anybody elaborate ?
It seems you are settings labelFrame but you are not using it.
Before using addSubView, ensure label is not nil
To configure the font and size of a UILabel use setFont: method passing a UIFont as parameter
To configure the color use .textColor property passing a UIColor as parameter