ben UICollectionView
(ilk kez) bir uygulamaya am ile clipsToBounds saygı göstermiyor. Çerçevenin ortasındaki her kiremitin solda ve sağda kısmen görünür kardeşi fayanslarıyla gösterilmesini isterim (Safari uygulamasında sayfa seçici gibi bir şey). Dahili hücre dequeueing yararlanmak için UICollectionView
kullanarak ilgileniyor ve döndürme UITableView
kullanmamayı tercih ediyorum.
Sayı
ben buluyorum sorunu pagingEnabled = YES
ve clipsToBounds = NO
kullanırken, UICollectionView
en kısa sürede çağrı tamamlanır tamamlanmaz (onlar visibleCells
dizide değiliz) collectionView
çerçevenin dışında hücreleri kaldırır olmasıdır. Bu temel kurulumu korurken, kız kardeşlerin önizlemelerini gösterme etkisinin nasıl elde edileceği konusunda tavsiyelerde bulunabilir mi? Yoksa buna yanlış mı yaklaşıyorum?
Ekran ekranı kaydırma ucunun
kaydırma
başlangıç tam doğrudur. Ama başlangıç ve bitiş fotoğraflarında mavi kenarlarda yeşil görünmesini istiyorum. Ben CollectionView'ın konusunda uzman değilim
#import "AppDelegate.h"
@interface ViewController : UICollectionViewController
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"ID"];
[self.view setBackgroundColor:[UIColor blueColor]];
// pad the collection view by 20 px
UIEdgeInsets padding = UIEdgeInsetsMake(20.0, 20.0, 20.0, 20.0);
[self.collectionView setFrame:UIEdgeInsetsInsetRect(self.view.frame, padding)];
// set pagingEnabled and clipsToBounds off
[self.collectionView setPagingEnabled:YES];
[self.collectionView setClipsToBounds:NO];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 5;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ID" forIndexPath:indexPath];
UILabel *label = [[UILabel alloc] initWithFrame:cell.bounds];
label.textAlignment = NSTextAlignmentCenter;
label.text = [NSString stringWithFormat:@"%d", indexPath.row];
[label setBackgroundColor:[UIColor greenColor]];
[cell.contentView addSubview:label];
return cell;
}
@end
@implementation AppDelegate
{
ViewController *vc;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// setup the UICollectionViewFlowLayout
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.itemSize = CGSizeMake(280, 280);
layout.minimumInteritemSpacing = 0;
layout.minimumLineSpacing = 0;
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
// add a custom UICollectionViewController to the window
vc = [[ViewController alloc] initWithCollectionViewLayout:layout];
self.window.rootViewController = vc;
self.window.backgroundColor = [UIColor yellowColor];
[self.window makeKeyAndVisible];
return YES;
}
@end
Bunun, 6 veya daha fazla hücreye sahip olana kadar çalıştığını gördük, bu noktada hücreler görünüm çerçevesinde olsalar bile kaybolacaktır. Söz konusu hücre her iki komşu hücrenin arkasında * olduğunda (bu, araştırmayı durdurduğumuz yer) gerçekleşir. –
Bu çalışmayı iOS 8'de, yeni iPhone boyutlarında ve Autolayout'u destekleyemiyorum. –