ios - UICollectionView 水平滚动不会滚动到最后一项
<p><p>我遇到了一个问题,我无法滚动到水平 <code>UICollectionView</code> 中的最后一项。我该如何解决这个问题?下面是我的视频和我的项目文件的链接,因为它很难解释。希望有人可以帮助我解决这个问题。 </p>
<p>提前谢谢你。</p>
<p> <a href="https://drive.google.com/file/d/0BwvEaCrhg6dTbkdTRUYwTjhNN2c/view?usp=sharing" rel="noreferrer noopener nofollow">https://drive.google.com/file/d/0BwvEaCrhg6dTbkdTRUYwTjhNN2c/view?usp=sharing</a> </p>
<p> <a href="https://youtu.be/8WVyrUl4qfQ" rel="noreferrer noopener nofollow">https://youtu.be/8WVyrUl4qfQ</a> </p>
<p>这是我的具有 UICollectionView 的 UIViewcontroller 代码:</p>
<pre><code>@synthesize dummyArrayImage,dummyArrayLabel,dummyDictionary,dummyArrayDescriptionLabel;
- (void)viewDidLoad {
;
// Do any additional setup after loading the view.
dummyArrayImage = [ initWithObjects:@"1",@"2",@"3",@"4",@"5", nil];
dummyArrayLabel = [ initWithObjects:@"RM 3.00",@"RM 10.00",@"RM 5.90",@"RM1.20",@"RM 8.10", nil];
dummyArrayDescriptionLabel = [ initWithObjects:@"Tesco Choco Milk",@"Tesco Sardin",@"Ayam Goreng",@"Ikan Pari",@"Itik", nil];
dummyDictionary = @{@"image":dummyArrayImage, @"label":dummyArrayLabel, @"description":dummyArrayDescriptionLabel};
NSLog(@"dummy dictionary : %@", dummyDictionary);
NSLog(@"dummy array : %@", dummyArrayImage);
NSLog(@"dummy array count : %d", (int)dummyArrayImage.count);
NSLog(@"dummy dictionary count : %d", (int)dummyDictionary.count);
}
- (void)didReceiveMemoryWarning {
;
// Dispose of any resources that can be recreated.
}
#pragma mark - UICollectionView
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return dummyArrayImage.count;
}
// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
TezCollectionViewCell *cell = ;
UIImage *contentImage = ];
cell.contentImageView.image = contentImage;
cell.titleLabel.text = dummyArrayDescriptionLabel;
cell.descriptionLabel.text = dummyArrayLabel;
return cell;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我自己想出来的。发生此问题是因为我正在使用自动布局。我尝试使用自动布局约束,突然它按预期工作。感谢所有回答我问题的人。你们真棒。干杯。 </p></p>
<p style="font-size: 20px;">关于ios - UICollectionView 水平滚动不会滚动到最后一项,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/33298902/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/33298902/
</a>
</p>
页:
[1]