콜렉션 뷰를 사용 중입니다. 하나의 이미지를 탭하면 다음 스크린으로 이동합니다. 여기서 사용자는 텍스트 뷰에서 그림의 세부 사항을 입력 할 수 있으며, 사용자가 저장 버튼을 누르면 두 번째보기 컨트롤러 텍스트를 저장하고 첫 번째보기 컨트롤러로 이동해야하며이 이미지를 표시하기위한 한 개의 기호를 넣어야합니다. 그러한 문자가 있습니다콜렉션 뷰
내가 한 일은 터치 된 이미지를 저장하는 사전 하나를 만들었습니다 두 번째보기 컨트롤러에서 입력 한 문자열과 키 및 값으로 .i 사용자가 이전 화면으로 이동하면 기호를 표시하고 싶지 않습니다. 날이
//collection view methods
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView*)collectionView
{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [self.imageArray count];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
PicturesCollectionViewCell *Cell1 = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell1" forIndexPath:indexPath];
NSLog(@"%@",self.imageArray);
Cell1.self.imageView.image=[self.imageArray objectAtIndex:indexPath.row];
Cell1.layer.borderWidth = 2.0f;
Cell1.layer.borderColor = [UIColor blackColor].CGColor;
//button to tap
UIButton *tapButton = [[UIButton alloc]init];
tapButton.frame = CGRectMake(0, 0, 96, 82);
[tapButton addTarget:self action:@selector(Tap:) forControlEvents:UIControlEventTouchUpInside];
[tapButton setTag:indexPath.row];
[Cell1.contentView addSubview:tapButton];
self.imageSelected = [self.imageArray objectAtIndex:indexPath.row];
NSLog(@" the image is:%@",self.imageSelected);
return Cell1;
}
-(IBAction)Tap:(id)sender
{
UIButton *btn = (UIButton *)sender;
self.key = @(btn.tag);
int tag = [self.key intValue];
self.imageSelected = [self.imageArray objectAtIndex:tag];
NSLog(@" image selected in picture confirm screen %@",self.imageSelected);
NotesViewController *NotesVC = [self.storyboard instantiateViewControllerWithIdentifier:@"NotesVC"];
NotesVC.self.notes_Array = self.imageSelected;
[self.navigationController pushViewController:NotesVC animated:YES];
}
2nd view controller -Notes View Controller
- (IBAction)bnt_Save_Notes:(id)sender {
if (self.txtview_Notes.text.length == 0) {
[StaticHelper showAlertWithTitle:nil message:@"Notes Should Not be empty" onViewController:self];
}
else
{
self.string = self.txtview_Notes.text;
NSLog(@" the noted string is :%@",self.string);
PicViewController *PictureVC = [self.storyboard instantiateViewControllerWithIdentifier:@"PictureVC"];
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init];
[dict setObject:self.string forKey:self.notes_Array];
[self.navigationController popViewControllerAnimated:YES];
}
몇 가지 아이디어가이 일을 말 해주세요 할 도와주세요.
테이블 경로를 다시로드하면 셀에 체크 표시가 나타납니다. –
Thanks @Teja Nandamuri하지만 첫 번째보기 컨트롤러에 사전을 보내지 않았습니다. 그리고 어디 컬렉션보기 셀을 다시로드해야합니다. 사용자가 세부 사항을 입력 한 동일한 그림을 터치하면 입력 된 텍스트가 두 번째보기 컨트롤러에 있어야합니다.이 – user6183984
코드의 이상한 서식을 읽지 않는 것이 좋습니다. – vikingosegundo