这是我的ViewController.m文件的Collection视图代码:
- (void)viewDidLoad
{
img = [[NSArray alloc] initWithObjects:@"1.png",@"2.png",@"3.png", nil];
name = [[NSArray alloc] initWithObjects:@"Flag",@"Blue",@"Fish", nil];
[self.collectionview registerNib:[UINib nibWithNibName:@"cell" bundle:nil] forCellWithReuseIdentifier:@"CELL"];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [img count];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell1 = [collectionview dequeueReusableCellWithReuseIdentifier:@"CELL" forIndexPath:indexPath];
UIImageView *reciveimageview = (UIImageView *)[cell1 viewWithTag:100];
reciveimageview.image = [UIImage imageNamed:[img objectAtIndex:indexPath.row]];
cell1.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:[img objectAtIndex:indexPath.row]]];
cell1.cellLabel.text = [name objectAtIndex:indexPath.row];
return cell1;
}
@end
现在它给了我Undeclared identifier of Cell and Cell1
的错误
不知道为什么。
答案 0 :(得分:2)
像这样添加 static NSString * identifier = @" Cell&#34 ;;
// GridView1_NeedDataSource
protected void GridView1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
BindGridViewData();
}
//Bind Grid View
private void BindGridViewData()
{
var table = new DataTable();
table .Columns.Add("Source");
table .Columns.Add("Destination");
table .Columns.Add("Date");
if()
{
foreach (var item in data)
{
table.Rows.Add(Source,Destination,Date);
}
//Binding to Gridview
GridView1.DataSource = dt;
}
else
{
GridView1.DataSource = dt;
}
}
答案 1 :(得分:1)
答案 2 :(得分:0)