Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIPopoverController顶部内的UITableViewController不可见_Ios_Uitableview_Uipopovercontroller - Fatal编程技术网

Ios UIPopoverController顶部内的UITableViewController不可见

Ios UIPopoverController顶部内的UITableViewController不可见,ios,uitableview,uipopovercontroller,Ios,Uitableview,Uipopovercontroller,我有一个UITableViewController用作UIPopoverController中的内容视图控制器。不幸的是,表视图的内容被从顶部切掉了,我可以尝试向下滚动到很远的地方,然后看到它,尽管它会反弹到顶部。有点像这样: Table view content starts up here (what I want in the middle of the popover) --------------- | bottom | | of

我有一个
UITableViewController
用作
UIPopoverController
中的内容视图控制器。不幸的是,表视图的内容被从顶部切掉了,我可以尝试向下滚动到很远的地方,然后看到它,尽管它会反弹到顶部。有点像这样:

Table view content starts up here (what I want in the middle of the popover)

    ---------------
    |  bottom     |
    |   of        |
    |   table     |
    |   view      |
    ---------------

我的
表格视图
远高于
UIPopoverController
的折叠是否有原因?

由您设置UIPopoverController的
popoverContentSize
以适应其内容视图控制器的视图。

使用此设置popOverController的内容大小

//Calculate how tall the view should be by multiplying 
//the individual row height by the total number of rows.
NSInteger rowsCount = [_colorNames count];
NSInteger singleRowHeight = [self.tableView.delegate tableView:self.tableView 
    heightForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
NSInteger totalRowsHeight = rowsCount * singleRowHeight;

//Calculate how wide the view should be by finding how 
//wide each string is expected to be
CGFloat largestLabelWidth = 0;
for (NSString *colorName in _colorNames) {
    //Checks size of text using the default font for UITableViewCell's textLabel. 
    CGSize labelSize = [colorName sizeWithFont:[UIFont boldSystemFontOfSize:20.0f]];
    if (labelSize.width > largestLabelWidth) {
        largestLabelWidth = labelSize.width;
    }
}

//Add a little padding to the width
CGFloat popoverWidth = largestLabelWidth + 100;

//Set the property to tell the popover container how big this view will be.
self.contentSizeForViewInPopover = CGSizeMake(popoverWidth, totalRowsHeight);
复制自,我现在正在将其用于我的应用程序:)