Я создал uitext view, как показано ниже:
in the h.file
@property (nonatomic, retain) NSString *strDescription;
in the m file
@synthesize strDescription;
- (void)viewDidLoad
{
GRect frame = CGRectMake(0, 0, 320, 369);
tblAddEquipment = [[UITableView alloc] initWithFrame:frame style:UITableViewStyleGrouped];
tblAddEquipment.delegate = self;
tblAddEquipment.dataSource = self;
//avoid reusable
[self.view addSubview:tblAddEquipment];
self.tableView.scrollEnabled = YES;
//self.tblAddEquipment.scrollEnabled = NO;
[tblAddEquipment release];
[self.tableView setSeparatorColor:[UIColor clearColor]];
}
- (void)textViewDidEndEditing:(UITextView *)textView
{
strDescription = textView.text;
NSLog(@"strDescription textView#####################--> %@", strDescription);
[tblAddEquipment reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"str Description in tableview--> %@", strDescription);
UITextView *txtDescription;
cellRectangle = CGRectMake( 175, 1, 120, 40 );
txtDescription = [[UITextView alloc] initWithFrame: cellRectangle];
txtDescription.font = font;
//txtDescription.scrollEnabled = YES;
txtDescription.textColor = [UIColor blackColor];
txtDescription.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview:txtDescription];
txtDescription.returnKeyType = UIReturnKeyDone;
txtDescription.delegate = self;
txtDescription.tag = 10;
NSString *strDesc = strDescription;
NSLog(@"strDesc in tableview--> %@", strDesc);
txtDescription.text = strDesc;
[txtDescription release];
}
Когда я завершу ввод текста в textview, вызывается метод textViewDidEndEditing
.
В этом я получаю textView
ввод текста.Я храню его в переменной strDescription
.Я могу напечатать это там.Он показывает назначенный ему текст правильно.
Но когда вызывается метод cellForRowAtIndexPath
, я попытался напечатать переменную strDescription
, но он вылетает и показывает exc_bad_access
.
Я давно сталкиваюсь с этой проблемой.Я не знаю, что я делаю здесь не так.Пожалуйста, помогите мне встать.