2010-05-21 4 views

답변

4

응용 프로그램에서 NSForm을 사용할 수있는 여러 가지 방법이 있습니다.

  • 프로그래밍에 의해 NSForm을 만들고 창보기에 그 NSform를 첨부하여 펜촉 파일에 NSForm 추가

    1. . 2 @

    나는 내가이 시작하는 데 도움이해야한다고 생각 당신이

    NSWindow*window  = [self window]; // gets current widnow 
    NSView *theContentView = [window contentView]; // gets view from window 
    
    NSRect contentRect = [theContentView frame]; // gets frame from view 
    
    NSRect formRect = NSMakeRect(0, 50, 300, 220); // creates new frame 
    
    NSForm *theForm; 
    theForm = [[NSForm alloc] initWithFrame:formRect]; // init with frame fromRect 
    
    NSFormCell *theFormCell; // create cell for form 
    
    // defines first cell with field First Name 
    theFormCell = [theForm addEntry:@"First Name:"]; 
    [theFormCell setTag:EContactFieldTag_FirstName]; 
    
    // defines first cell with field Last Name 
    theFormCell = [theForm addEntry:@"Last Name:"]; 
    [theFormCell setTag:EContactFieldTag_LastName]; 
    
    [theForm setCellSize:NSMakeSize(300, 25)]; // defines size for cell 
    [theForm sizeToCells]; 
    
    [theForm setKeyCell:theFormCell]; // assign cell to form 
    
    [theContentView addSubview:theForm]; // add form to current view 
    

    을 이해할 수있는 나와 함께 하나의 예를 가지고있다.

    궁금한 점이 있으면 알려주세요.

  • +0

    네, 작동 괜찮습니다. 이제 NSFormcell 값을 하나의 배열에서 얻고 싶습니다. 어떻게 가능합니까? – mikw

    +0

    하나의 배열을 만들고 루프를 반복하여 다음과 같이 셀을 만들 수 있습니다. NSInteger i = 0; for (id * array_data의 항목) { theFormCell = [theForm addEntry : (NSString *) item]; [theFormCell setStringValue : [[NSString alloc] initWithFormat : @ "% d", i]]; [theFormCell setTag : i]; // 모든 nscell에 대해 tag diff를 가짐 \t i ++; } 배열의 모든 항목에 대해 셀을 생성하고 값을 넣습니다. –

    관련 문제