2013-06-27 85 views
0

爲什麼我的UICollecionView的滾動不順暢?UICollectionView滾動不平滑。爲什麼?

這是代碼:

static NSString *CellIdentifier = @"cellRecipe"; 

// Configure the cell... 

[cell setBackgroundColor: [UIColor colorWithPatternImage:[UIImage imageNamed:@"bgRecipeCell.png"]]]; 

cell.image.layer.masksToBounds = YES; 
cell.image.layer.cornerRadius = 8.0f; 
cell.image.layer.borderColor = [UIColor blackColor].CGColor; 
cell.image.layer.borderWidth = 1.0f; 

Recipes *recipe = [recipesArray_ objectAtIndex:indexPath.item]; 

//checking for purchase 
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; 
NSObject *object = [prefs objectForKey:@"com.__.__.recipefree"]; 

if ([recipe.isPaid integerValue] == 0) { 
    [cell.freeImage setHidden:NO]; 
} 
else [cell.freeImage setHidden:YES]; 

if ([object isEqual:[NSNumber numberWithInt:1]]) { 
    [cell.freeImage setHidden:YES]; 
} 

if ([recipe.isFavorite integerValue] == 0) { 
    [cell.favImage setImage:[UIImage imageNamed:@"toFavorite.png"] ]; 
} 
else [cell.favImage setImage: [UIImage imageNamed:@"toFavorite_.png"]]; 

[cell.recipeName setText: recipe.name]; 
[cell.image setImage:recipe.thumbImage]; 

MainTabController *mainTabController = [[MainTabController alloc] init]; 
int difficulty = [recipe.difficulty intValue]; 
//this is the function which return an image for difficulty level from 1 to 5 
[cell.difficultyImage setImage: [mainTabController imageForRating:difficulty]]; 

return cell; 
+3

可能是因爲cell.image.layer的。 cornerRadius = 8.0f ;.嘗試評論代碼並運行一次以確認。最好有bgRecipeCell.png圓角和邊框。 – iCoder

+0

還要確保'png'文件不透明(在模擬器中可以通過選擇Debug-> Color Blended Layers來實現)。阿爾法混合是一個昂貴的操作,如果你能避免它會顯着提高你的表現。 – StatusReport

+0

@StatusReport:我已刪除的PNG文件,但仍然滾動不順暢(( – Romowski

回答

0

在我的情況下,該層的邊界被打破了平滑度。正如我真想邊界在那裏,我不能使用圖片(背景顏色必須是可變的),我用下面的UIView層次解決它:

UIView with rounded corners coloured with "border colour" 
    UIView with rounded corners coloured with "content colour"