开发者

not resulting in redraw when called from viewController

开发者 https://www.devze.com 2023-02-12 13:50 出处:网络
I have a subview with various methods that update my data and then call[self setNeedsDisplay]; to invoke the drawRect to update the view. 开发者_JS百科

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

开发者_JS百科

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?


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];
0

精彩评论

暂无评论...
验证码 换一张
取 消