I am adding a custom view dynamically and i get this exception
EXCEPTION: ; symbol stub for: getpid
ITMCustomView *cView = [[ITMCustomView alloc] initWithFrame:CGRectMake(187, 660, 400, 400)
andOrderedItem:@"dd"
andTag:self.tagNumber
withFoldArray:self.foldTypeArray
withRollArray:self.rollTypeArray];
cView.delegate = self;
//set properties of cView...like cView.txtName.text =@"John";
//self.scrollView.contentSize = CGRectMake(187, 660, 400, 400).size;
/*CGPoint scrollPoint = CGPointMake(0.0, (cView.frame.origin.y/800)*400);
[self.scrollView setContentOffset:scrollPoint animated:YES];
[self.scrollView addSubview:cView];
CGFloat scrollViewHeight = 0.0f;
for (UIView *view in self.scrollView.subviews)
{
scrollViewHeight += view.frame.size.height;
}
CGSize newSize = CGSizeMake(320,scrollViewHeight);
//CGRect newFrame = (CGRect){CGPointZero,newSize};
[self.scrollView setContentSize:newSize];
NSLog(@"750 the tag number is %d",self.tagNumber);
NSLog(@"the scroll view height is %f",scrollViewHeight);
self.currentCGRectLocation = cView.frame;*/
There is a lot of code above which i have commented in /* */ .Before that also i have one line
//self.scrollView.contentSize = CGRectMake(187, 660, 400, 400).size;
If i uncomment the above line it starts getting the exception. I come to this code at another point in my application. When i first launch the app this code gets called and it works fine. Now i save the records on this screen-A and go do some other calculation(basically go to another screen- B) and come back to this screen and i retrieve the saved record and display it, just display it on screen A and then i get this exception. What i have noticed is anything I do with scroll view is giving an exception. If i leave out this line
[self.scrollView addSubview:cView];
outside the comments then i can see the custom view added perfectly fine..but i loose my scrolling..the screen is stuck..So issue is sort of with scroll view i think.Please let me know if you need any more info. Thanks..
EDIT : changed to this..still does not work.
ITMCustomView *cView = [[ITMCustomView alloc] initWithFrame:CGRectMake(187, 660, 400, 400)
andOrderedItem:@"New"
andTag:self.tagNumber
withFoldArray:self.foldTypeArray
withRollArray:self.rollTypeArray];
cView.tag =self.tagNumber;
NSLog(@"Assigned tag is %d",cView.tag);
cView.delegate = self;
CGPoint scrollPoint = CGPointMake(0.0, (cView.frame.origin.y/500)*400);
[self.scrollView setContentOffset:scrollPoint animated:YES];
[self.scrollView addSubview:cView];
CGFloat scrollViewHeight = 0.0f;
for (UIView *view in self.scrollView.subviews)
{
scrollViewHeight += view.frame.size.height;
}
CGSize newSize = CGSizeMake(320,scrollViewHeight);
//CGRect newFrame = (CGRect){CGPointZero,newSize};
[self.scrollView setContentSize:newSize];
NSLog(@"the scroll view height is %f",scrollViewHeight);
self.currentCGRectLocation = cView.frame;
for (NSObject *newObj in cView.subviews)
{
if ([newObj isMemberOfClass:[UITextField class]])
{
UITextField *txtObj = (UITextField *)newObj;
switch (txtObj.tag) {
case 6: //Length
NSLog(@"6 item value is %@",txtObj.text);
txtObj.text = [soliI.length stringValue]; //[NSString stringWithFormat:@"%1.1f",length];
break;
case 7: //Width
NSLog(@"7 item value is %@",txtObj.text);
txtObj.text = [soliI.width stringValue]; //[NSString stringWithFormat:@"%1.1f",width];
break;
default:
break;
}
}
else if ([newObj isMemberOfClass:[UITextView class]])
{
UITextView *txtView = (UITextView *)newObj;
NSLog(@"the tag is %d",txtView.tag);
if (txtView.tag == 17)
{
txtView.text = soliI.specialInstructions;
}
}
else if ([newObj isKindOfClass:[UIButton class]])
{
UIButton *btn = (UIButton *)newObj;
NSLog(@"btn tag is %d",btn.tag);
switch (btn.tag) {
case 12:
[btn setTitle:@"Fold" forState:UIControlStateNormal];
break;
case 13:
[btn setTitle:@"Roll" forState:UIControlStateNormal];
break;
default:
break;
}
}