apfrod
apfrod

Reputation: 341

not resulting in redraw when called from viewController

I have a subview with various methods that update my data and then call [self setNeedsDisplay]; to invoke the drawRect to update the view.

If I call one of these methods from the viewController, the data gets updated but the drawRect is not called.

The subView is added as a property of the viewController: @property (nonatomic,retain) MyView *myView;

and initiated in the viewController:

@synthesize myView;

 - (void)viewDidLoad {
    [super viewDidLoad];

    myView = [[MyView  alloc] init]; 

    }

I call a method on myView later in the viewController with [myView exampleMethod];

How can I make sure methods called from the viewController redraw the subView?

Upvotes: 1

Views: 717

Answers (1)

Nicki
Nicki

Reputation: 984

Won't you have to call

[self.view setNeedsDisplay];

:)

The default view in a view controller is called just "view" if you want to make your own, you have to add it to that or exchange the view with that, like this:

self.view = myView;
//or
[self.view addSubview:myView];

Upvotes: 1

Related Questions