目前我的应用程序使用时使用,当我在等待Web服务如何处理内存管理自定义模式对话框安装/拆卸
@implementation AddModalDialog
- (void)buildModalDialogWithTextForView:(NSString *)text:(UIViewController *)controller
{
UIView* _hudView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 400, 450)];
_hudView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
_hudView.clipsToBounds = YES;
UIActivityIndicatorView* _activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
_activityIndicatorView.frame = CGRectMake(140, 135, _activityIndicatorView.bounds.size.width, _activityIndicatorView.bounds.size.height);
[_hudView addSubview:_activityIndicatorView];
[_activityIndicatorView startAnimating];
UILabel* _captionLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 190, 250, 22)];
_captionLabel.backgroundColor = [UIColor clearColor];
_captionLabel.textColor = [UIColor whiteColor];
_captionLabel.font = [UIFont systemFontOfSize:13.0];
_captionLabel.adjustsFontSizeToFitWidth = NO;
_captionLabel.textAlignment = UITextAlignmentCenter;
_captionLabel.text = text;
[_hudView addSubview:_captionLabel];
[controller.view addSubview:_hudView];
}
- (void)removeModalDialogForView:(UIViewController *)controller
{
NSUInteger i, count = [controller.view.subviews count];
[[controller.view.subviews objectAtIndex:(count - 1)] removeFromSuperview];
}
@end
我的问题是有关内存管理的自定义模式对话框对象这个对象。在上面的自定义UIView内可能会注意到的任何东西都是值得欢迎的,因为它确实有改进的空间。
下面是我目前的工作瓦特/这在我的其他对象时,我想拉起模式
- (void)viewDidLoad
{
AddModalDialog* modal = [[AddModalDialog alloc] init];
[modal buildModalDialogWithTextForView:@"Loading some details ..." :self];
[modal release];
}
然后Web服务后完成我通常称之为推倒
- (void)returnWebServiceDetails:(MyClass *)obj
{
AddModalDialog* modal = [[AddModalDialog alloc] init];
[modal removeModalDialogForView:self];
[modal release];
}
我不应该初始化这个对象两次,而是有一个属性?新的obj-c开发人员正在寻找围绕此行为的最佳实践。
预先感谢您
哇 - 这是一些答案!感谢您为此付出的所有努力! – 2011-01-24 01:12:17