开发者

Programmatically changing width or height not working for Mac app

I have a very strange issue. I need to programmatically increase my TableView height. But programmatic frame change in terms of width or height isn't been aplied. Is there some other way of changing frames in Cocoa?

I’m using the following code:

-(IBAction )topButtonClicked:(id)sender{
    if(testView.isHidden == NO){
      开发者_开发技巧  [testView setHidden:YES];
        [tableView setFrame:NSMakeRect(0,595, 666,595+120)];
}
    else {
        [tableView setFrame:NSMakeRect(0,595, 666,595)];
        [testView setHidden:NO];
    }
}

Programmatically changing width or height not working for Mac app


By default, a table view is enclosed in a scroll view and the scroll view is configured to automatically resize its subviews. This means that changing the table view frame alone won’t work because the enclosing scroll view will autoresize it.

You should change the frame of the enclosing scroll view instead. For example:

[[tableView enclosingScrollView] setFrame:NSMakeRect(0,595, 666,595+120)];

or you could have an outlet for the scroll view:

[tableScrollView setFrame:NSMakeRect(0,595, 666,595+120)];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜