0
在我的表格視圖中,我想在ios中顯示一些標題,所以我可以如何做到這一點。我的代碼在下面給出...因爲我想顯示數據像..... ..... 名稱類RollNo地址 在表視圖然後該怎麼做這..任何人都可以幫助我?表格視圖數據以特定格式顯示?
enter code here
deliveryCases = [[UITableView alloc]initWithFrame:CGRectMake(20, 20, 320, 480)];
deliveryCases.backgroundColor = [UIColor clearColor];
deliveryCases.dataSource = self;
deliveryCases.delegate = self;
[self.view addSubview:deliveryCases];
UIView *headerView0 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100 , 50)];
UILabel *labelView0 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100 , 50)];
labelView0.text = @"Name";
[headerView0 addSubview:labelView0];
deliveryCases.tableHeaderView = headerView0;
UIView *headerView1 = [[UIView alloc] initWithFrame:CGRectMake(10, 19, 100 , 50)];
UILabel *labelView1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 19, 100 , 50)];
labelView1.text = @"CLass";
[headerView1 addSubview:labelView1];
deliveryCases.tableHeaderView = headerView1;
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [deliveryCases dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell==nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
[cell setUserInteractionEnabled:YES];
tableView.allowsSelection=YES;
return cell;
}
-(NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
有沒有什麼辦法來添加表視野... ????? –
是的,就像你在你的單元格中添加標籤所做的一樣,只需在你的單元格中添加UITextField ...如果你想確定一個特定的字段,可以在你的字段中添加標籤並通過他們的標籤訪問它們 –