我是ios開發的新手。我搜索了許多使用許可證密鑰的數據網格框架的教程。我想在給定的link處顯示類似此表的數據。我如何使用uicollection視圖來顯示鏈接中的表格數據? 在gridview.h文件的代碼是:如何使用uicollectionview在表格中顯示數據
進口@interface GridViewCell : UITableViewCell
@property (nonatomic, strong) UIButton *column1;
@property (nonatomic, strong) UIButton *column2;
@property (nonatomic, strong) UIButton *column3;
@end
在gridview.m文件中的代碼是:
//
// GridViewCell.m
// SQLite3DBSample
//
// Created by Dezine House on 22/12/2014.
// Copyright (c) 2014 Bilal ARSLAN. All rights reserved.
//
#define CELL_WIDTH 100
#define CELL_HEIGHT 80
#import "GridViewCell.h"
@implementation GridViewCell
@synthesize column1, column2, column3;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
column1 = [[UIButton alloc] initWithFrame:CGRectMake(5, 5, CELL_WIDTH, CELL_HEIGHT)];
[self addSubview:column1];
column2 = [[UIButton alloc] initWithFrame:CGRectMake(CELL_WIDTH+ 10, 5, CELL_WIDTH, CELL_HEIGHT)];
[self addSubview:column2];
column3 = [[UIButton alloc] initWithFrame:CGRectMake(CELL_WIDTH + CELL_WIDTH + 15, 5, CELL_WIDTH, CELL_HEIGHT)];
[self addSubview:column3];
}
return self;
}
- (void)awakeFromNib
{
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
GridViewCell *cell = (GridViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[GridViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
[cell.column1 setBackgroundColor:[UIColor blackColor]];
[cell.column2 setBackgroundColor:[UIColor blackColor]];
[cell.column3 setBackgroundColor:[UIColor blackColor]];
return cell;
}
@end
歡迎來到Stack Overflow!我想你已經嘗試了一些東西。如果是這樣,那麼請[編輯](http://stackoverflow.com/posts/27615866/edit)您的文章並添加您的代碼,以便我們可以使用一些東西。請參閱[tour](http://stackoverflow.com/tour)並閱讀[如何提問](http://stackoverflow.com/questions/how-to-ask)以瞭解我們對問題的期望。 – honk