문제

According to the NSTableHeaderView class reference, an NSTableHeaderView uses an NSTableHeaderCell class to implement its user interface.

NSTableHeaderView uses NSTableHeaderCell to implement its user interface.

NSTableHeaderView Class Reference

Okay, so now I subclassed my NSTableHeaderCell and did the necessary changes but how do I assign my custom NSTableHeaderCell to an NSTableHeaderView?

도움이 되었습니까?

해결책

    Try like this:-

    #import <Cocoa/Cocoa.h>

    @interface customHeaderCell : NSTableHeaderCell
    {

    }

    @end

    #import "customHeaderCell.h"

    @implementation customHeaderCell

    -(id)initTextCell:(NSString *)aString
    {
   if([aString isEqualToString:@"yourHeaderCell"])
{
    // do your stuff here;
}
        return [super initTextCell:aString];
    }

    @end


    Now in other class wherever your table view you are using write the following the code:-

    -(IBAction)addData:(id)sender
    {
        for (NSTableColumn *col in [tableView tableColumns])
        {
            customHeader=[[customHeaderCell alloc]initTextCell:[col identifier]];

        }

    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top