3

JSON を使用して入力した UICollectionView があります。映画のポスターを使ったカバーフロー風のレイアウトです。

画面上の特定のポイントにセルのタイトル プロパティを表示して、水平方向にスクロールすると、中央に表示されているセルのタイトルが表示されるようにする方法があるかどうか疑問に思っていました。

indexPathForItemAtPoint を使用してみましたが、コレクション ビューでポイントがスクロールするようで、常に同じインデックスが表示されます。

編集:コードの追加:

UIView *test = [[UIView alloc] initWithFrame:CGRectMake(10, 30, self.view.frame.size.width+180, 390)];
test.backgroundColor = [UIColor clearColor];
superView.backgroundColor = [UIColor blackColor];


PerspectiveFlowLayout *layout = [[PerspectiveFlowLayout alloc]init];
self.boxes.bounces = NO;

BoxView *boxes = [[BoxView alloc] initWithFrame:test.frame collectionViewLayout:layout];


[test addSubview:boxes];
[superView addSubview: test];
NSIndexPath *path = [self.boxes indexPathForItemAtPoint:[self.boxes convertPoint:CGPointMake(100.0, 100.0) toView:[self.boxes superview]]];

Cell *atpoint = [self.boxes cellForItemAtIndexPath:path];


NSLog(@"%@", atpoint.model.name);

助けてくれてどうもありがとう、ローガン

4

1 に答える 1

1

変換ポイントを実行するときにアイテムを交換してみてください。これにより、スーパービューからコレクション ビューに移動します。

NSIndexPath *path = [self.boxes indexPathForItemAtPoint:[[self.boxes superview] convertPoint:CGPointMake(100.0, 100.0) toView:self.boxes]];
于 2013-09-12T20:23:45.983 に答える