如何在UITableViewCell
边界之外的UITableView
添加视图?
在iOS 6上,会出现蓝色视图,但滚动时会消失。在iOS7上,蓝色视图根本不显示。任何帮助。感谢。
- (void)viewDidLoad
{
[super viewDidLoad];
UITableView *aTableView = [[UITableView alloc] initWithFrame:CGRectMake(100, 100, 100, 100) style:UITableViewStylePlain];
aTableView.dataSource = self;
aTableView.delegate = self;
[self.view addSubview:aTableView];
// Do any additional setup after loading the view, typically from a nib.
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.frame = CGRectMake(0, 0, 200, 44);
UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
redView.backgroundColor = [UIColor redColor];
UIView *blueView = [[UIView alloc] initWithFrame:CGRectMake(100, 0, 100, 44)];
blueView.backgroundColor = [UIColor blueColor];
tableView.contentSize = CGSizeMake(200, 100);
[cell.contentView addSubview:redView];
[cell.contentView addSubview:blueView];
return cell;
}
答案 0 :(得分:-2)
tableView.layer.masksToBounds = NO;
?