내 NSRect가 BrightnessView.m에서 그려지고 있으며 "밝기"라는 xib의 NSView의 사용자 정의 클래스에 연결되어 있습니다. PanelController는 "controller"라는 또 다른 xib에 연결되어 있으며 슬라이더가 동작하는 곳입니다. Panel Controller.h는보기가있는 xib과 동일한 xib에 연결되어 있지 않으므로 BrightnessView에 대한 콘센트를 가질 수 없습니다. 콘센트 대신 밝기보기에 대한 포인터가 필요하거나이 기능을 사용할 수 있습니까? 나는 일반 포인터 만이 실 거예요 작업SetNeedsDisplay not drawing NSRect
XIB에있는 파일 소유자에 연결// 패널 Controller.h "컨트롤러"
#import "BrightnessView.h"
@interface PanelController : NSWindowController
{
BrightnessView *_myBrightnessView;
}
@property (assign) BrightnessView *BrightnessView;
@end
// 패널 Controller.m을 추가
@synthesize BrightnessView = _myBrightnessView;
- (IBAction)sliderChange:(id)sender;
{
[_myBrightnessView.self setNeedsDisplay:YES];
}
//BrightnessView.m xib의 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은이 프로젝트의 한 예이며 어떻게 작동하지 않습니다.
나는 그것을 가리 키도록 업데이트했지만 여전히 다시 그리지 않을 것이다. 미안 해요 임 객차 -c에서 새로운 –
'brightnessView' 콘센트가 연결되어 있습니까? 'sliderChange :'에서'NSLog'를 사용하여 검사해야합니다. –
나는 코드를 쌓아 넣기 위해 코드를 단순화하려고 시도했지만 왜 실제로 작동하지 않는지를 보여주기 위해 코드를 업데이트했다. 그들은 별도의 xib에 연결되어 있고 패널 컨트롤러에서 밝기보기 –