0

我在 xib 文件上添加了 Tableview(您可以在图像上看到)。tableview 加载良好。但是最后一个单元格不在屏幕上,所以当我向上滑动时显示最后一个索引。当我离开我的手时,最后一个单元格没有出现。我不改变 tableview 的任何高度。为什么不固定在我的屏幕上?

我在这个项目中使用了像 facebook 这样的显示菜单:https ://github.com/mikefrederick/MFSideMenu

您也可以在电影中看到问题。

https://www.dropbox.com/s/usfwdhl5w9znkl6/IMG_0006.MOV

电影:

视图控制器.h

@property(nonatomic,retain)IBOutlet UITableView * tableview;

视图控制器.m

-(void)viewDidAppear:(BOOL)animated
{
     self.tableview.backgroundColor=[UIColor colorWithRed:(28/255.0) green:(28/255.0) blue:(28/255.0) alpha:1];
     [self.tableview setSeparatorColor:[UIColor blackColor]];

}
- (void)viewDidLoad
{
    [super viewDidLoad];




    if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
        self.edgesForExtendedLayout = UIRectEdgeNone;

}
#pragma mark -
#pragma mark - UITableViewDataSource


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section==0)
    {
        return 5;
    }
    if (section==1)
    {
        return 3;
    }
    return 0;
}

- (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.textLabel.text =@"exampleCell";



    NSLog(@"cell.contentView.bounds.size.width %1.0f",cell.contentView.bounds.size.width);
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if(section == 1)
        return 40;
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
   self.tableview.layer.cornerRadius = 10.0f;
    tableView.layer.borderWidth = 2.0;
    tableView.layer.borderColor = [UIColor redColor].CGColor;
    return 60;


}
#pragma mark UITableViewDelegate
- (void)tableView: (UITableView*)tableView
  willDisplayCell: (UITableViewCell*)cell
forRowAtIndexPath: (NSIndexPath*)indexPath
{

    cell.backgroundColor =[UIColor colorWithRed:(41/255.0) green:(41/255.0) blue:(41/255.0) alpha:1];
    cell.textLabel.backgroundColor = [UIColor clearColor];
    cell.detailTextLabel.backgroundColor = [UIColor clearColor];
    if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row){
        //end of loading
        //for example [activityIndicator stopAnimating];

    }
}

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)];
    [headerView setBackgroundColor:[UIColor colorWithRed:(112/255.0) green:(112/255.0) blue:(112/255.0) alpha:1]];
    UILabel *titleLabel = [ [UILabel alloc] initWithFrame:CGRectMake(20, 0, 300, 44)];

    titleLabel.text = @"MÜŞTERİ ALANI";

    titleLabel.textColor = [UIColor whiteColor];

    titleLabel.backgroundColor = [UIColor clearColor];

    [headerView addSubview:titleLabel];
    return headerView;
}
4

3 回答 3

1

在您的视频中,此菜单似乎是一个滑出菜单,可能使用了一些第三方滑出菜单控制器库。所以这个视图控制器包含在一些容器视图中。滑出菜单控制器可能没有正确调整视图控制器的大小以适应其容器视图。

一种解决方案是检查您正在使用的滑出控制器随附的任何示例应用程序,以查看它们是否存在错误,如果是这种情况,请将其报告给开发人员。这会很好,因为其他开发人员将从改进中受益。事实上,您使用的滑出式控制器可能已经使用您还没有的更新版本修复了这个错误。

另一个解决方案,假设有一个示例应用程序没有受到这种影响,是查看它是如何添加滑出菜单的,看看你是否没有做他们正在做的事情。

最后,如果没有示例应用程序或者您无法弄清楚为什么他们的工作方式不同,请尝试将以下内容添加到您的视图控制器的viewDidAppear:方法中:

self.view.frame = self.view.superview.bounds;

这假设他们创建的容器视图大小合适。

于 2013-12-19T21:50:59.763 回答
0

您的问题似乎出在您的xib中。您必须将 View 的大小设置为“ Freeform ”,然后像在 tableView 上一样在视图上添加自动调整大小的约束。

自由形式

自动调整大小

于 2013-12-19T21:42:45.910 回答
0

首先,您应该选择 CELL,而不是 TABLE VIEW。接下来,转到属性检查器并单击分隔符,您应该选择自定义插入。最后,您可以根据自己的意愿调整分隔线。希望这会对您和其他人有所帮助。也谢谢你的问题。

于 2017-01-29T02:46:25.913 回答