Скрыть график в пользовательском UIView - PullRequest
1 голос
/ 14 апреля 2011

У меня есть пользовательский график просмотра и контроллер представления для этого представления GraphViewController. Я реализую простой график.

Вот код для Chart.h

#import 


@interface Chart : UIView {
    BOOL hideChart;
}
@property BOOL hideChart;
- (void) drawAxesInContext:(CGContextRef)context;
- (void) drawUserChartinContext:(CGContextRef)context;
@end

Chart.m


- (void)drawRect:(CGRect)rect
{
    CGContextRef ctxt = UIGraphicsGetCurrentContext();
    [self drawAxesInContext:ctxt]; 
    [self drawUserChartinContext:ctxt];
}

- (void) drawAxesInContext:(CGContextRef)context {
    CGContextTranslateCTM(context, nullX, nullY);
    CGContextScaleCTM(context, 1.0, -1.0);
    CGContextSetLineWidth(context, 3);
    CGContextBeginPath(context);   

    for (int i=0; i 

<p>As you can see on screenshot I have uibutton "hide". I want to hide graph (not axes) by pressing this button.
In viewController I created ibaction</p>

<pre>
- (IBAction) hideAndShow {
    self.chart.hideChart = YES;
}

и в поле зрения вы можете увидеть

if (hideChart) { [[UIColor blackColor] setStroke]; [self setNeedsDisplay]; NSLog (@ "скрыть"); }

Но это не работает, у вас есть идеи, как я могу это сделать? http://dl.dropbox.com/u/866144/Voila_Capture7.png

1 Ответ

0 голосов
/ 15 апреля 2011

Я предлагаю добавить пользовательский установщик для hideChart, примерно так

...