나는 카테고리 목록이있는 테이블 뷰가 있습니다. 사용자가 추가 버튼을 누르면 텍스트 필드가있는 alertview가 나타나고 '확인'버튼이 나타나고 텍스트 필드에 입력 된 텍스트가 테이블보기에 추가되어야합니다. 추가 할 수 있지만 plist.so에 추가되지 않습니다. 우리가 다른 시각으로 옮겨 와서 돌아 오면 그건 그냥 사라져 버리는거야.동적으로 입력 한 데이터를 plist에 저장합니다.
-(void)viewDidLoad
{
NSString *fileForCategoryList = [[NSBundle mainBundle] pathForResource:kCATEGORY_LIST ofType:kP_List];
self.arrayForCategories = [[NSMutableArray alloc]initWithContentsOfFile:fileForCategoryList];
}
- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[self.arrayForCategories removeObjectAtIndex:indexPath.row];
[self.tableViewC reloadData];
}
else if (editingStyle == UITableViewCellEditingStyleInsert)
{
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:kYOUR_TITLE message:kEMPTY delegate:self cancelButtonTitle:kCANCEL otherButtonTitles:kOK, nil];
self.myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[self.myTextField setBackgroundColor:[UIColor whiteColor]];
[myAlertView addSubview:self.myTextField];
[myAlertView show];
[myAlertView release];
}
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if ([self.myTextField text])
{
[self.arrayForCategories addObject:[self.myTextField text]];
}
[self.tableViewC reloadData];
}
약간의 코드 또는 링크와 관련이 있습니까? – Chandu
업데이트 된 답변 확인 – visakh7
ya thanx가 링크를 시도합니다. – Chandu