Pull to refresh Crash my application - ios

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.

Related

UITextFieldViewModeAlways cause crash of my app

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?

Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN

When I'm clicking button I'm getting this exception.I don't know where I'm doing wrong Someone help me .my app is rejected because of this exception
my code:
UILabel *rememberMeLabelObj = [[UILabel alloc]initWithFrame:CGRectMake(xaxisForRememberMeLabel, yaxisForRememberMeLabel, widthForRememberMeLabel, heightForRememberMeLabel)];
rememberMeLabelObj.text = #"Remember me";
rememberMeLabelObj.font =[UIFont systemFontOfSize:14.0];
rememberMeLabelObj.textColor = [UIColor colorWithRed:0.816f green:0.592f blue:0.157f alpha:1.00f];
[self.view addSubview:rememberMeLabelObj];
You are calling UILabel frame methods, and probably calculating the value somehow and the result is a NaN, which means "not a number" and, as you correctly suggested, it can be the result of o divide-by-zero operation.
But it can appear for a lot other reasons: http://en.wikipedia.org/wiki/NaN
Reference: kuba
I solved my issue actually I didn't gave float values because of this I got exception.I gave CGFloat and gave values as integer like 400,350,etc but I need give 400.0f .so,I got this issue .Now it was cleared
My iOS App has the same problem when the simulator version is 8.x, it is no problem in version 9.x,after I have checked and removed the following code, the problem is solved!
- (void)viewWillAppear:(BOOL)animated
{
[LoadTableView setContentOffset:CGPointMake(CGFLOAT_MAX, CGFLOAT_MAX)];
[super viewWillAppear:YES];
}
- (void)viewDidAppear:(BOOL)animated
{
[LoadTableView reloadData];
LoadTableView.hidden = 0;
[super viewDidAppear:YES];
}

Crash in ios7 while setting font on navigation bar

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",
}];`

Unrecognized selector sent to instance 0xa44bef0

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

iOS/iPhone :UIView not adding elements for NSMutableArray (containing UILabel objects)

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

Resources