我遇到了问题
当我点击tabcontoller uıcollectionviewflowlayout
位置正在改变时:(
以下代码不起作用
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
UICollectionViewFlowLayout *collectionViewLayout = (UICollectionViewFlowLayout*)self.myCollectionView.collectionViewLayout;
collectionViewLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
}
在图像之前:
当我点击tabcontoller时 在图像之后:
请帮帮我
其他图片上传
答案 0 :(得分:0)
<强>更新强> 删除
UICollectionViewFlowLayout *collectionViewLayout = (UICollectionViewFlowLayout*)self.myCollectionView.collectionViewLayout;
collectionViewLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
来自viewWillAppear
并将其放回viewDidLoad
。
答案 1 :(得分:0)
- (void)viewDidLoad
{
[self.myCollectionView registerNib:[UINib nibWithNibName:PhotoCellIdentifier bundle:[NSBundle mainBundle]]
forCellWithReuseIdentifier:PhotoCellIdentifier];
self.myCollectionView.delegate=self;
self.myCollectionView.dataSource=self;
[self.myCollectionView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
[self yukle];
}
-(void) storkontrol:(NSArray*)skulist{
[[RMStore defaultStore] requestProducts:[NSSet setWithArray:skulist] success:^(NSArray *products, NSArray *invalidProductIdentifiers) {
if (products.count ==0)
{
self.eserList = nil;
[self sitedeveriyokbilgi];
} else
{
NSMutableArray *ll = [[NSMutableArray alloc] init];
int i =0;
// satın alışverişte alınan ürünelr geliyor
// NSLog(@"RMStore dan ürünler bekleniyor..");
for (SKProduct*urun in products) {
// NSLog(@"ürün : %@",urun.productIdentifier);
for (EserFiles*eser in self.eserList) {
if ([urun.productIdentifier isEqualToString:eser.eser.eserstokkod])
{
eser.eser.product = urun;
[ll insertObject:eser atIndex:i];
i++;
}
}
}
// NSSortDescriptor *sortDesc = [[NSSortDescriptor alloc] initWithKey:@"eser.esersayi" ascending:NO selector:@selector(compare:)];
// [ll sortUsingDescriptors:[NSArray arrayWithObject:sortDesc]];
self.eserList = ll;
// [HesapViewController setEserListVitrin: ll];
// [AyarlarViewController setEserListVitrin: ll];
[global setEserListVitrin: ll];
// NSLog(@"RMStore dan ürün çekme işlemi bitti");
[self.myCollectionView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
_productsRequestFinished = YES;
[spinnerorta stopAnimating];
}
} failure:^(NSError *error) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[spinnerorta stopAnimating];
NSLog(@"failure:^(NSError *error urunlist %@",error.localizedDescription);
}];
}
-(void)sitedeveriyokbilgi{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 200, self.view.frame.size.width, 270)];
label.backgroundColor = [UIColor clearColor];
label.textAlignment = NSTextAlignmentCenter;
label.textColor = [UIColor grayColor];
label.numberOfLines = 0;
label.text = @"Listelenecek eser bulunamadı";
[self.view addSubview:label];
NSLog(@"Listelenecek eser bulunamadı");
[spinnerorta stopAnimating];
}
-(void)yukle{
spinnerorta = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
spinnerorta.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin|UIViewAutoresizingFlexibleTopMargin|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin;
spinnerorta.center = self.view.center;
[spinnerorta startAnimating];
[self.view addSubview: spinnerorta];
//eğer kategoriden geliyorsa hiç bir zamanön bellekleme olmayacak
__block NSArray *arry ;
NSMutableArray *skulist = [[NSMutableArray alloc] init];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
//ana sayfa ise
if (self.gelenviewid==1)
{
if ([[global getEserList] count] ==0 )
{
// NSLog(@"yeni liste alınıyor.......");
NSMutableArray *skulist = [[NSMutableArray alloc] init];
JSONLoader *jsonLoader = [[JSONLoader alloc] init];
arry = [jsonLoader locationsFromJSONFile];
} else{
self.eserList =[global getEserList];
// NSLog(@"ön bellekten doldu....");
[self.myCollectionView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
// [spinnerorta stopAnimating];
return ;
}
} else if(self.gelenviewid==2)
{
arry = [JSONLoader getEserlerToKategory:self.catId];
}
if ([arry count] >0)
{
self.eserList = arry;
for (EserFiles*eserfile in self.eserList) {
// NSLog(@"sayı :%d %@",eserfile.eser.esersayi,eserfile.eser.kisaisim);
[skulist addObject:eserfile.eser.eserstokkod];
}
// dispatch_async( dispatch_get_main_queue(),
// ^{
[self storkontrol:skulist];
// });
} else {
dispatch_async( dispatch_get_main_queue(),^{
[spinnerorta stopAnimating];
[self sitedeveriyokbilgi];
});
}
});
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section {
int count = self.eserList.count;
return count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath{
// [collectionView setContentInset:UIEdgeInsetsMake(0, 0, 0, 0)];
EserFiles *esefiles =[self.eserList objectAtIndex:indexPath.row];
Eser *eser = esefiles.eser;
UrunCell *urunCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"UrunCell" forIndexPath:indexPath];
UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
spinner.frame = CGRectMake((urunCell.frame.size.width-25)/2, 50, 24, 24);
[spinner startAnimating];
[urunCell.contentView addSubview: spinner];
NSString *title = @"";
if ([eser.kisaisim isKindOfClass:[NSNull class]] || [eser.kisaisim isEqualToString:@""]){
title = eser.isim;
} else title = eser.kisaisim;
urunCell.UrunIsim.text=title;
// NSLog(@"title : %@",title);
[urunCell.UrunImage sd_setImageWithURL:[NSURL URLWithString:eser.kapakYol]
placeholderImage:[UIImage imageNamed:@"placeholder"] options:indexPath.row == 0 ? SDWebImageRefreshCached : 0];
[spinner stopAnimating];
return urunCell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
self.vitrinDetayViewController =[self.storyboard instantiateViewControllerWithIdentifier:@"VitrinDetayViewController"];
EserFiles *esefiles =[self.eserList objectAtIndex:indexPath.row];
self.vitrinDetayViewController.eser = esefiles;
[self.navigationController pushViewController:self.vitrinDetayViewController animated:YES];
}
- (void)viewWillAppear:(BOOL)animated {
// [self.myCollectionView setContentOffset:CGPointZero animated:NO];
[super viewWillAppear:animated];
UICollectionViewFlowLayout *collectionViewLayout = (UICollectionViewFlowLayout*)self.myCollectionView.collectionViewLayout;
// collectionViewLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
//[self.myCollectionView setContentOffset:CGPointZero animated:NO];
// self.automaticallyAdjustsScrollViewInsets = NO;
[spinnerorta stopAnimating];
}