사람이 나를 UIViewController
에서 this- 같은 (아이 패드 iOS7에 대한 개발)을 달성하는 데 도움이 될 수 있습니다 제발 내가 jQuery과 UICollectionView
(같은 splitViewController
) .I 그냥 내가 UITableViewCell
에 누를 때 UICollectionView
에서 이미지를 변경하고 싶습니다. (나는 & 사용하고 있습니다 button
이상 tableViewCell
및 수집 색인 NSInteger
).UITableView 및 UICollectionView 상호 작용 기능은 무엇입니까?
나는 이것을 달성하는 데 도움이된다. 나는 여러 날 동안 노력하고 있지만 지금까지는 달성 할 수 없다. . :(여기
내가 지금까지 무엇을했는지 코드 내viewDidLoad
에서
: CollectionViewMethods
에서 다음
self.collectionViewImages=[[NSMutableArray alloc]initWithObjects:@"1.jpg",@"2.jpg",@"3.jpg",nil] ;
:
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView
numberOfItemsInSection:(NSInteger)section
{
return [_collectionViewImages count];
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *myCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Cell"
forIndexPath:indexPath];
NSString *collectionViewImageName=[self.collectionViewImages objectAtIndex:indexPath.row];
UIImageView * collectionImage = (UIImageView*)[myCell viewWithTag:11];
collectionImage.image =[UIImage imageNamed:collectionViewImageName];
return myCell;
}
다음에 ButtonClick (ofTableViewCell) - - (각 버튼의 태그를 NSInteger
에 수집하고 해당 속성을 numberOfItemsInSection
에 사용 중입니다. 이 같은
-(void)btnTapped:(id)sender{
int tag= [(UIButton *)sender tag];
NSLog(@"Button Pressed%d",tag);
_buttonIndex=tag;
//_buttonIndex is NSInteger property
//If i add object in NSMutableArray and call reloadData my UI hangs here only.
//If I empty my NSMutableArray and add new objects in it and then call reloadData, I am getting NSRangeException.
}
그리고 지금은 numberOfItemsInSection
에서이 속성을 사용하고 ...
if (_buttonIndex==1){
[collectionImage setImage:[UIImage imageNamed:[_array1 objectAtIndex:indexPath.row]]];
//My _array1 has 4 objects and my collectionViewImages array has 7 objects.
}
당신이 시도하고 있기 때문에
*** Terminating app due to uncaught exception 'NSRangeException',
reason: '*** -[__NSArrayM objectAtIndex:]: index 4 beyond bounds [0 .. 3]'
@Cyrille 질문이 업데이트되었습니다. –