我在我的應用程序中有設計,就像我在UITableView中有4個部分,我需要在同一個表的各個部分之間插入UIImageView和UILabel。是否有可能這樣做?如何在UITableView的兩部分之間插入UIImageView?
請告訴我一個path.Thank你。
我在我的應用程序中有設計,就像我在UITableView中有4個部分,我需要在同一個表的各個部分之間插入UIImageView和UILabel。是否有可能這樣做?如何在UITableView的兩部分之間插入UIImageView?
請告訴我一個path.Thank你。
看到這些的UITableViewDelegate方法:
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger) section
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section
您可能需要封閉的容器IUView圖像視圖和標籤,並從這些方法之一返回容器。這取決於你想要展示的內容和方式。
我認爲你需要做它有四個獨立的表與每一個部分的自定義視圖,並把ImageView的每個表之間的的UILabel。
是您的表樣式?
如果是這樣,請使用viewForHeaderInSection:
或viewForFooterInSection:
方法UITableViewDelegate
。創建視圖,將圖像和標籤添加到視圖中,然後從上述兩個委託方法中的任何一個返回到視圖。我想,你正在使用圖像和標籤作爲部分的標題。所以,tableView:viewForHeaderInSection:
是你需要的。
我以這種方式實現的,它顯示了按我的need.Thank圖像您顯示的路徑,我顯示的情況下別人是need.Thank你的代碼。
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger) section
{
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0,5,320,40)];
UIImageView *imgAdbar = [[UIImageView alloc]initWithFrame:CGRectMake(header.frame.origin.x,header.frame.origin.y,header.frame.size.width,header.frame.size.height)];
[imgAdbar setImage:[UIImage imageNamed:@"ad2.png"]];
[header addSubview:imgAdbar];
header.backgroundColor = [UIColor clearColor];
return header;
}