0
我試圖實現ibooks書架功能,我使用GSBookShelf這是非常簡單和直接,它添加按鈕作爲單元格,它的作品很棒。桌面與自定義UIView,添加標籤重疊
我想爲每個按鈕添加一些標籤,但我偶爾可以說一次5個標籤中的2個與前面的按鈕標籤重疊。
通常這樣
有時出現這種情況:
代碼:
- (UIView *)bookShelfView:(GSBookShelfView *)bookShelfView bookViewAtIndex:(NSInteger)index {
NSDictionary *currentArticle = [_bookArray objectAtIndex:index];
static NSString *identifier = @"bookView";
MyBookView *bookView = (MyBookView *)[bookShelfView dequeueReuseableBookViewWithIdentifier:identifier];
if (bookView == nil) {
bookView = [[MyBookView alloc] initWithFrame:CGRectZero];
bookView.reuseIdentifier = identifier;
[bookView addTarget:self action:@selector(bookViewClicked:) forControlEvents:UIControlEventTouchUpInside];
}
[bookView setIndex:index];
[bookView setSelected:[(NSNumber *)[_bookStatus objectAtIndex:index] intValue]];
//[bookView setFileName:[currentArticle objectForKey:@"name"] ];
//[bookView setFileName:[currentArticle objectForKey:@"name"] :index];
UIImage *image = nil;
image = [self returnCellImagefor:[currentArticle objectForKey:@"imagename"]];
[bookView setBackgroundImage:image forState:UIControlStateNormal];
UILabel *_fileLabel=nil;
_fileLabel =[[UILabel alloc] initWithFrame:CGRectMake(0, 180, 200, 46)];
_fileLabel.text=[currentArticle objectForKey:@"name"];
_fileLabel.textColor=[UIColor whiteColor];
_fileLabel.backgroundColor=[UIColor clearColor];
_fileLabel.font = [UIFont fontWithName:@"Gill Sans" size:16];
//_fileLabel.textAlignment=UITextAlignmentCenter;
_fileLabel.textAlignment = NSTextAlignmentCenter;
_fileLabel.numberOfLines=0;
_fileLabel.lineBreakMode = UILineBreakModeWordWrap;
[_fileLabel sizeToFit];
[bookView addSubview:_fileLabel];
return bookView;
}
形象都不錯,他們從來沒有重疊,但標籤是否有時。
任何想法,爲什麼發生這種情況?
謝謝,我最終標記每個標籤,並在每次分配新標籤之前從超級視圖中刪除它 –