私のNSRectはBrightnessView.mで描画されており、「brightness」と呼ばれるxib上のNSViewのカスタムクラスに接続されています。PanelControllerは、「コントローラー」と呼ばれる別のxibに接続されており、スライダーがアクションとともに配置されます。Panel Controller.hは、ビューのあるxibと同じxibに接続されていないため、BrightnessViewへのアウトレットを持つことはできません。コンセントの代わりに、明るさのビューへのポインターだけが必要ですか、それともこれは機能しますか?通常のポインタを追加しましたが、これは機能しません
//xib"Controller"のファイル所有者に接続されたPanelController.h
#import "BrightnessView.h"
@interface PanelController : NSWindowController
{
BrightnessView *_myBrightnessView;
}
@property (assign) BrightnessView *BrightnessView;
@end
//パネルコントローラー.m
@synthesize BrightnessView = _myBrightnessView;
- (IBAction)sliderChange:(id)sender;
{
[_myBrightnessView.self setNeedsDisplay:YES];
}
//BrightnessView.mはxib「Brightness」のNSViewに接続されています
- (void)drawRect:(NSRect)theRect
{
NSLog(@"the view is drawn");
NSRect contentRect = NSInsetRect([self bounds], 0, 0);
NSBezierPath *path = [NSBezierPath bezierPath];
[path moveToPoint:NSMakePoint(_arrowX, NSMaxY(contentRect))];
[path lineToPoint:NSMakePoint(_arrowX / 2, NSMaxY(contentRect))];
[path lineToPoint:NSMakePoint(NSMaxX(contentRect), NSMaxY(contentRect))];
NSPoint topRightCorner = NSMakePoint(NSMaxX(contentRect), NSMaxY(contentRect));
[path curveToPoint:NSMakePoint(NSMaxX(contentRect), NSMaxY(contentRect))
controlPoint1:topRightCorner controlPoint2:topRightCorner];
[path lineToPoint:NSMakePoint(NSMaxX(contentRect), NSMinY(contentRect))];
NSPoint bottomRightCorner = NSMakePoint(NSMaxX(contentRect), NSMinY(contentRect));
[path curveToPoint:NSMakePoint(NSMaxX(contentRect), NSMinY(contentRect))
controlPoint1:bottomRightCorner controlPoint2:bottomRightCorner];
[path lineToPoint:NSMakePoint(NSMinX(contentRect), NSMinY(contentRect))];
[path curveToPoint:NSMakePoint(NSMinX(contentRect), NSMinY(contentRect))
controlPoint1:contentRect.origin controlPoint2:contentRect.origin];
[path lineToPoint:NSMakePoint(NSMinX(contentRect), NSMaxY(contentRect))];
NSPoint topLeftCorner = NSMakePoint(NSMinX(contentRect), NSMaxY(contentRect));
[path curveToPoint:NSMakePoint(NSMinX(contentRect), NSMaxY(contentRect))
controlPoint1:topLeftCorner controlPoint2:topLeftCorner];
[path lineToPoint:NSMakePoint(_arrowX / 2, NSMaxY(contentRect))];
[path closePath];
[the_Color setFill];
[path fill];
[NSGraphicsContext saveGraphicsState];
NSBezierPath *clip = [NSBezierPath bezierPathWithRect:[self bounds]];
[clip appendBezierPath:path];
[clip addClip];
[NSGraphicsContext restoreGraphicsState];
}
- (void)setArrowX:(NSInteger)value
{
_arrowX = value;
}
www.mediafire.com/?66q8jv3vly1cch4は、このプロジェクトの例であり、どのように機能しないかを示しています。