zoukankan      html  css  js  c++  java
  • NSSplitView

    本文代码最终实现界面为

    两种方法可以实现divider的上下拖动:

    1.调用NSSplitViewDelegate

    /* Given a proposed position for one of the dividers of a split view, return a position at which the divider should be placed as the user drags it. If a split view has no delegate, or if its delegate does not respond to this message, the split view behaves as if it has a delegate that responds to this message by merely returning the proposed position. If a split view has a delegate, and the delegate responds to this message, it will be sent repeatedly as the user drags one of the split view's dividers.

    */

    - (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex;

    用此方法要先设置splitview的delegate为当前app([_splitOuter setDelegate:self];)或

     

    - (CGFloat)splitView:(NSSplitView *)splitView constrainSplitPosition:(CGFloat)proposedPosition ofSubviewAt:(NSInteger)dividerIndex

    {

         NSLog(@"split view is being dragged");

        CGFloat position = proposedPosition;

        return position;

    }

    2.调用通知

    - (void) splitViewDidResizeSubviews:(NSNotification *)notification

    //- (void) splitViewDidResizeSubviews:(NSNotification *)notification

    //{

    //    

    //    NSSplitView *split = [notification object];

    //    NSString *splitName = [split identifier];

    //    

    ////    NSLog(@"split name is %@",[split identifier]);

    //    

    //    NSArray *allviews = [split subviews];

    //    

    //    if ([splitName isEqualToString:@"split_outer"]) {

    //        //1.修改split_outer.topview中控件的大小位置

    //        NSView *topView = [allviews objectAtIndex:0];

    //        [[self.textViewConsole enclosingScrollView] setFrame:[topView frame]];

    //        

    //        NSView *bottomView = [allviews objectAtIndex:2];

    //        NSSize bottomSize = [bottomView frame].size;

    //        NSRect bottomRect = {0,0,bottomSize.width,bottomSize.height};

    //        [[self.tableViewProgress enclosingScrollView] setFrame:bottomRect];

    //        

    //        //2.修改split_outer.bottomview中控件的大小位置

    //        NSView *middleView = [allviews objectAtIndex:1];

    //        NSRect middleRect = [middleView frame];

    //        

    //        NSLog(@"x:%f,y:%f,w:%f,h:%f",middleRect.origin.x,middleRect.origin.y,middleRect.size.width,middleRect.size.height);

    //        

    //        //3. 修改split_outer.middle下拉动时对应其它控件的大小

    //        NSPoint point = NSMakePoint(0, 0);

    //        [self.splitInner setFrameOrigin:point];

    //        [self.splitInner setFrameSize:middleRect.size];

    //        

    //        NSArray *innerSubViews = [self.splitInner subviews];

    //        

    //        NSView *leftTableViewOuterView = [innerSubViews objectAtIndex:0];

    //        NSSize leftTableViewOuterViewSize = [leftTableViewOuterView frame].size;

    //        [[self.leftTableView enclosingScrollView] setFrameSize:leftTableViewOuterViewSize];

    //        [[self.leftTableView enclosingScrollView] setFrameOrigin:point];

    //        

    //        NSView *rightTableViewOuterView = [innerSubViews objectAtIndex:1];

    //        NSSize rightTableViewOuterViewSize = [rightTableViewOuterView frame].size;

    //        [[self.rightTableView enclosingScrollView] setFrameSize:rightTableViewOuterViewSize];

    //        [[self.rightTableView enclosingScrollView] setFrameOrigin:point];

    //        

    //    } else if([splitName isEqualToString:@"split_inner"]){

    //        NSLog(@"xxxxxxx");

    //        

    //         NSPoint point = NSMakePoint(0, 0);

    //        NSArray *innerSubViews = [self.splitInner subviews];

    //        

    //        NSView *leftTableViewOuterView = [innerSubViews objectAtIndex:0];

    //        NSSize leftTableViewOuterViewSize = [leftTableViewOuterView frame].size;

    //        [[self.leftTableView enclosingScrollView] setFrameSize:leftTableViewOuterViewSize];

    //        [[self.leftTableView enclosingScrollView] setFrameOrigin:point];

    //        

    //        NSView *rightTableViewOuterView = [innerSubViews objectAtIndex:1];

    //        NSSize rightTableViewOuterViewSize = [rightTableViewOuterView frame].size;

    //        [[self.rightTableView enclosingScrollView] setFrameSize:rightTableViewOuterViewSize];

    //        [[self.rightTableView enclosingScrollView] setFrameOrigin:point];

    //

    //    }

    //}

     

    最后设置size inspector

    每个view都要设置

     

     http://i.cnblogs.com/Files.aspx

     

  • 相关阅读:
    RHEL 6.3安装(超级详细图解教程)[转载]
    CentOS下设置vimrc,添加文件注释信息以及设置tab 键为4 格
    Centos 设置时区和时间以及增加中文输入法
    虚拟机上CentOS6.5 无法上网的解决方法
    LoadRunner 11安装及测试环境搭建
    LR11录制回放出现中文乱码以及录制时一直跳到360浏览器的解决方法
    第 3 章 变量和表达式
    第 2 章 编写 C# 程序
    第 1 章 C# 简介
    jQuery Mobile的学习时间bottonbutton的事件学习
  • 原文地址:https://www.cnblogs.com/huibin-benteng/p/4913244.html
Copyright © 2011-2022 走看看