ios - Table View 窗外屏幕 iOS objective C

标签 ios objective-c uitableview uitextfield

我在 Storyboard中为我的文本字段设置了约束。我想使用以下代码在文本字段下创建一个 TableView 。设置类似于 textfield.frame.size.width 的宽度会使 tableView 一直超出屏幕,为什么?请帮忙。

-(void)cofigureAutoComTableView
{

    autocompleteTableView = [[UITableView alloc] initWithFrame:CGRectMake(self.txtActivity.frame.origin.x,self.txtActivity.frame.origin.y+32,self.txtActivity.frame.size.width, 200) style:UITableViewStylePlain];

    autocompleteTableView.delegate = self;
    autocompleteTableView.dataSource = self;
    autocompleteTableView.scrollEnabled = YES;
    //autocompleteTableView.
    autocompleteTableView.hidden = YES;
    [self.view addSubview:autocompleteTableView];

    CALayer *layer = autocompleteTableView.layer;
    [layer setMasksToBounds:YES];
    [layer setCornerRadius: 4.0];
    [layer setBorderWidth:1.0];
    [layer setBorderColor:[[UIColor blackColor] CGColor]];
}

Pics

最佳答案

看起来是因为当 textview 很长时你正在调用函数,所以在 viewDidAppear 中使用它

[self cofigureAutoComTableView];

关于ios - Table View 窗外屏幕 iOS objective C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49359887/

相关文章:

iphone - MPMoviePlayer 完成按钮问题

iphone - 如何使表达式在 iOS 上可点击?

ios - ONTapGesture 不适用于动态创建的 View

ios - IBOutlet nil 一切看起来都正常

objective-c - 将 iPhone 应用程序转换为 iPad,然后在 iPad 中使用 splitview?

ios - 用户取消 IAP ios sdk 时如何更新 UI

iphone - 使用证书、 key 和信任编程指南中的代码示例时出现“extractIdentityAndTrust”错误和警告

带有 Cookie 的 Objective-C 异步 Web 请求

ios - 可扩展表格 View 单元格 - 使用单元格问题

ios - 有条件地将单元格数据添加到 NSMutableArray