开发者

Releasing dynamically added UILabel

开发者 https://www.devze.com 2023-01-02 21:48 出处:网络
I am adding a no. of UILable dynamically to my view like thi开发者_如何转开发s UILabel *test = [[UILabel alloc] initWithFrame:CGRectMake(x, y, 50, 50)];

I am adding a no. of UILable dynamically to my view like thi开发者_如何转开发s

UILabel *test = [[UILabel alloc] initWithFrame:CGRectMake(x, y, 50, 50)];  
[self.view addSubview:tick];

Is it necessary to release these UILabel from memory in viewDidUnLoad and dealloc, if yes how i will release them? how i will get their reference?


Yes.

Since self.view already -retained the label in -addSubview:, you can -release it immediately.

UILabel *test = [[UILabel alloc] initWithFrame:CGRectMake(x, y, 50, 50)];  
[self.view addSubview:test];
[test release]; // <--
0

精彩评论

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