• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - 重新定位 UITableView

[复制链接]
菜鸟教程小白 发表于 2022-12-12 15:40:00 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我有一个 View Controller

  1. subview (主视图大小的一半)
  2. 表格 View (主视图大小的一半)
  3. 导航栏按钮

单击按钮时,我希望隐藏 subview 并以完整的主视图大小显示表格 View ....它在下面的代码中运行良好,但不是第一次。 当我第一次单击栏按钮时,它会隐藏 subview 并调整表格 View 的大小,但不会在屏幕上显示结果(适用于所有时间)。 如果我在第一次单击导航栏之前滚动表格 View ,它可以正常工作......我认为它与表格 View 加载有关,我无法理解

代码

if(isMapVisible==YES) {
    [mapView setHidden:YES];
    [tblView setFrame:CGRectMake(self.view.frame.origin.x,
                                 self.view.frame.origin.y+self.navigationController.navigationBar.frame.size.height+[UIApplication sharedApplication].statusBarFrame.size.height,
                                 self.view.frame.size.width, 
                                 self.view.frame.size.height-self.navigationController.navigationBar.frame.size.height-[UIApplication sharedApplication].statusBarFrame.size.height-self.navigationController.tabBarController.tabBar.frame.size.height)];

    isMapVisible=NO;
} else {
    [mapView setHidden:NO];
    [tblView setFrame:CGRectMake(mapView.frame.origin.x,
                                 mapView.frame.origin.y+mapView.frame.size.height+1,
                                 mapView.frame.size.width,
                                 mapView.frame.size.height)];

    isMapVisible=YES;
}


- (UITableViewCell *)tableViewUITableView *)tableView cellForRowAtIndexPathNSIndexPath *)indexPath {

    activityCell *cell = (activityCell*)[tableView dequeueReusableCellWithIdentifier"activityCell" forIndexPath:indexPath];

    return cell;
}
- (NSInteger)tableViewUITableView *)tableView numberOfRowsInSectionNSInteger)section {
    return 10;
}

- (CGFloat)tableViewUITableView *)tableView heightForRowAtIndexPath:    (NSIndexPath *)indexPath {
    return 100;
}



Best Answer-推荐答案


这样调用你的方法

[self performSelectorselector(methodToChangeTableViewFrame) withObject:nil afterDelay:0.1f];

-(void)methodToChangeTableViewFrame {

        // Here your code
    if(isMapVisible==YES) {
        [mapView setHidden:YES];
        [tblView setFrame:CGRectMake(self.view.frame.origin.x,
                                     self.view.frame.origin.y+self.navigationController.navigationBar.frame.size.height+[UIApplication sharedApplication].statusBarFrame.size.height,
                                     self.view.frame.size.width, 
                                     self.view.frame.size.height-self.navigationController.navigationBar.frame.size.height-[UIApplication sharedApplication].statusBarFrame.size.height-self.navigationController.tabBarController.tabBar.frame.size.height)];

        isMapVisible=NO;
    } else {
        [mapView setHidden:NO];
        [tblView setFrame:CGRectMake(mapView.frame.origin.x,
                                     mapView.frame.origin.y+mapView.frame.size.height+1,
                                     mapView.frame.size.width,
                                     mapView.frame.size.height)];

        isMapVisible=YES;
    }
}

关于ios - 重新定位 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31070355/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap