【发布时间】:2013-03-15 09:33:46
【问题描述】:
我下载了Collection View example,并用文本字段替换了 ImageView。 我想让文本字段和 UICollectionViewCell 一样大(这是一个正方形)。但是文本字段的形状没有改变。
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *identifier = @"Cell";
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
// height and width in the parent cell
double height = cell.frame.size.height;
double width = cell.frame.size.width;
// get the child textfield
UITextField *textField = (UITextField *)[cell viewWithTag:100];
// make the textfield as big as the cell
CGRect frame = CGRectMake(0, 0, width, height);
textField.frame =frame;
textField.text = @"testing";
return cell;
}
【问题讨论】:
标签: ios objective-c ios6 uitextfield uicollectionview