我已将以下变量声明为实例变量并在我的 m 文件中使用它,但是我收到了警告。
TransparentToolbar *tools;
在线分配的对象的潜在泄漏...
例如,我尝试为它创建一个属性..
@property (nonatomic, retain) TransparentToolbar *tools;
并合成并释放它,但我的视图在 dealloc 结束时崩溃。
我究竟做错了什么 ?
在 pickerSortingDataCurrent 上编辑相同的警告...
h
@interface myViewController : UIViewController <UIActionSheetDelegate,
UIPickerViewDelegate, UIPickerViewDataSource, UITableViewDelegate,
UITableViewDataSource, MFMailComposeViewControllerDelegate> {
TransparentToolbar *tools;
NSArray *pickerSortingDataCurrent;
}
@property (nonatomic, retain) TransparentToolbar *tools;
@property (nonatomic, retain) NSArray *pickerSortingDataCurrent;
m
@synthesize pickerSortingDataCurrent;
@synthesize tools;
- (void)viewDidLoad {
[super viewDidLoad];
tools = [[[TransparentToolbar alloc]
initWithFrame:CGRectMake(0, 0, 70, 44.01)] autorelease];
tools.barStyle = UIBarStyleBlackOpaque;
self.pickerSortingDataCurrent = [[NSArray alloc] initWithObjects:
@"Next Date Ascending",
@"Next Date Descending", nil]; // removed some items here
}
- (void)dealloc {
[tools release];
[pickerSortingDataCurrent release];
[super dealloc];
}
啊啊我有自动释放....但这并不能解决pickerSortingDataCurrent ...
编辑...
#import "TransparentToolbar.h"
@implementation TransparentToolbar
- (void)drawRect:(CGRect)rect {
// do nothing in here
}
- (void) applyTranslucentBackground
{
self.backgroundColor = [UIColor clearColor];
self.opaque = NO;
self.translucent = YES;
}
- (id) init
{
self = [super init];
[self applyTranslucentBackground];
return self;
}
// Override initWithFrame.
- (id) initWithFrame:(CGRect) frame
{
self = [super initWithFrame:frame];
[self applyTranslucentBackground];
return self;
}
@end
进一步编辑