2014-01-07 102 views
0

我有一个UITableViewController被用作UIPopoverController里面的内容视图控制器。不幸的是,桌面视图内容正在被切断,我可以尝试向下滚动并看到它,尽管它反弹回顶端。的排序是这样的:UIPopoverController里面的UITableViewController不可见

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

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

是否有一个原因,我tableView是在UIPopoverController倍以上呢?

回答

1

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

1

使用此设置你的popOverController从Ray's tutorial复制

//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); 

,这是我现在用我的应用程序:)

的contentSize
相关问题