DaffodilGirl 2013-04-07 02:50 采纳率: 0%
浏览 5639
已采纳

tableView占满整个屏幕

在app中需要用到一个小 tableView ,我设置了尺寸,但是运行之后 tableview 占了整个屏幕。

 -(void)viewDidLoad{
 UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 20.0, 60.0) style:UITableViewStylePlain];
   self.view = tableView;
 }
   - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyCellIdentifier = @"MyCellIdentifier";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:MyCellIdentifier];
if(cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyCellIdentifier];
}
return cell;
   }
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
  }
  • 写回答

2条回答 默认 最新

  • 半瓶子咣当 2013-04-07 03:03
    关注

    self.view = tableView;
    改成
    [self.view addSubview:tableView];

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作