SORU
25 Temmuz 2013, PERŞEMBE


UİCollectionView bir program aracılığıyla oluşturmak

Im basit bir UİCollectionView sadece kod kullanarak nasıl bana gösterecek bir rehber arıyorsanız veya öğretici.

** 4 ve İm the reference manual kullanarak da İm wading.

Ama ben gerçekten faydası basit bir yol göster bana nasıl kurmak UİCollectionView kalmadan kullanın Şeritleri veya XİB/UÇ dosyalarını - ama ne yazık ki ben arama hakkında, tüm bulurum. öğreticiler bu özellik film Şeridi.

CEVAP
25 Temmuz 2013, PERŞEMBE


Dosya:-- başlık

@interface ViewController : UIViewController<UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
{
    UICollectionView *_collectionView;
}

Uygulama Dosyası:--

- (void)viewDidLoad
{
     [super viewDidLoad];
     self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

     UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc] init];
    _collectionView=[[UICollectionView alloc] initWithFrame:self.view.frame collectionViewLayout:layout];
    [_collectionView setDataSource:self];
    [_collectionView setDelegate:self];

    [_collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"cellIdentifier"];
    [_collectionView setBackgroundColor:[UIColor redColor]];

    [self.view addSubview:_collectionView];


    // Do any additional setup after loading the view, typically from a nib.
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 15;
}

// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];

    cell.backgroundColor=[UIColor greenColor];
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(50, 50);
}

Çıktı---

enter image description here

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Gigawipf

    Gigawipf

    18 ŞUBAT 2010
  • Matt Stokes

    Matt Stokes

    22 Ocak 2008
  • Motor Trend Channel

    Motor Trend

    11 Mart 2006