我需要有2種行。一個有高度的44 PX和其他與90像素:IOS TableView行高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0)
return 90.0;
else
return 44.0;
}
問題是,當我叫 - (UITableViewCell的*)的tableView:(UITableView的*)的tableView的cellForRowAtIndexPath:(NSIndexPath *)indexPath因爲我需要添加到90px的單元格,它有90px的高度,但它被添加在單元格的中間,而不是頂部。
if (indexPath.section == 0) {
cell = [tableView dequeueReusableCellWithIdentifier:ScrolledCellIdentifier];
if (cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ScrolledCellIdentifier];
//cell.textLabel.text = @"hi";
[cell addSubview:self.scrollView];
}
嘗試設置單元格的作品爲textLabel,問題是增加了滾動。
如果我這一行添加到代碼:
self.scrollView.frame = CGRectMake(0,-45, 320, 90);
它完美,但它聽起來有些怪異我。發生什麼事?
只是爲了澄清 - 你爲什麼需要調整滾動視圖的框架? – theTRON 2012-02-07 21:42:28
,因爲如果我不調整框架,它需要高度44像素謝謝! – xger86x 2012-02-08 02:48:03