I am working with Custom UITableCell and dynamic UITextView in my application.
I have one issue regarding ios7 which i explain as follows:
i have created one view on UITable Cell Custom Button click like as follows. this view contains UITextView to input the text and fell it on cell later as on comment table.
// For iOS7
UITableView *table = nil;
if([CommonFunction isiOS7]){
table = (UITableView*)[[[[[sender superview] superview] superview] superview] superview];
indexPath=[[NSIndexPath alloc] init];//
indexPath = [table indexPathForCell:self];
}
else {
indexPath=[[NSIndexPath alloc] init];//
indexPath = [(UITableView *)self.superview indexPathForCell: self];
}
NSLog(@"indexPath:%@",indexPath);
if (appDelegate.dictLogedInUserData) {
//[(UITableView*)self.superview scrollToRowAtIndexPath:[(UITableView *)self.superview indexPathForCell:self] atScrollPosition:UITableViewScrollPositionTop animated:YES];
[table scrollToRowAtIndexPath:[table indexPathForCell:self] atScrollPosition:UITableViewScrollPositionTop animated:YES];
TextInputView *txtInput = [[TextInputView alloc] init];
txtInput.delegate=self;
if ([btnAddComment.titleLabel.text length]>0) {
if (![btnAddComment.titleLabel.text isEqualToString:@"Add Comment"]) {
txtInput.txtComments.text = btnAddComment.titleLabel.text;
}
}
txtInput.backgroundColor = [UIColor clearColor];
//[(UITableView*)[self superview] setScrollEnabled:NO];
[table setScrollEnabled:NO];
[self addSubview:txtInput];
[self bringSubviewToFront:txtInput];
}
When use enter some text i need to fill this UITextView text value to my UITableCell CustomView which code is as follows,This is delegate method:
//InputText Delegates
- (void)didFinishInput:(NSString *)inputedText {
btnAddComment.titleLabel.text = inputedText;
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:indexPath, @"indexPath",
[NSString stringWithFormat:@"%@",inputedText],@"commentText",nil];
NSLog(@"dict:%@",dict);
topic *t = [appDelegate.arrayTopicsData objectAtIndex:indexPath.row];
t.user_comment = inputedText;
[appDelegate.arrayTopicsData replaceObjectAtIndex:indexPath.row withObject:t];
[self LoadDataForIndex:indexPath];
[delegate didAddComment:dict];
[(UITableView*)[self superview] setScrollEnabled:YES];
if ([inputedText length]<=0) {
btnAddComment.titleLabel.text = @"Add Comment";
}
}
In the above code it always crash when i enter text on UITextView and press Done button of key board. it gives EXE-BAD-Access on indexPath in iOS7.
Please help me how to get Indexpath on UITextView delegate method when i am passing NSString to the Method.
Please help me.