将应用程序升级到iOS 5时的内存管理

时间:2012-03-18 16:31:46

标签: iphone memory-management uipickerview ios4 ios5.1

我有一个带有UIPickerView的小型iOS转换器(三列)和一个允许交换第一列和第三列的按钮(我交换两个相应的UILabel数组)

在iOS4.3 iphone模拟器下,一切都很好。当我使用iOS 5.1模拟器时出现显示问题(使用LLDB显示iVars也存在问题,而使用GDB消失了):

交换第一个和第三个数组后,6个UILabel在UIPickerView的第一列中激活(array:pickerColumn1),但是没有显示三个文本标签......

声明用于管理UIPickerView三列的三个数组:

//文件:MesureViewController.h

@interface MesureViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource> {
IBOutlet UIPickerView *pickerView;

NSArray *pickerColumn1;
NSArray *pickerColumn2;
NSArray *pickerColumn3;

// (...)
}
@property (nonatomic, retain) NSArray *pickerColumn1;
@property (nonatomic, retain) NSArray *pickerColumn2;
@property (nonatomic, retain) NSArray *pickerColumn3;

//文件:MesureViewController.m

@implementation MesureViewController
@synthesize pickerColumn1;
@synthesize pickerColumn2;
@synthesize pickerColumn3;

UiPickerView数组初始化(在viewDidLoad调用的方法中):

NSArray *contenants=[[NSArray alloc] initWithObjects:c_cafe, c_dessert, c_soupe, tasse, gtasse, bol, v_liqueur,v_moutarde, v_grand, nil];
NSArray *ingredients=[[NSArray alloc] initWithObjects: farine, sucre, beurre, marga, huile, creme, rape, fecule, semoule, f_sec_pile, sel, cereale, fruitfrais, miel, siropErable, cacao, cafe, riz, liquide , nil];
NSArray *mesures=[[NSArray alloc] initWithObjects: kilo, gramme, litre, dl, cl, ml, nil];
self.pickerColumn1=contenants; // 9 objects
self.pickerColumn2=ingredients; // 19 objects
self.pickerColumn3=mesures; // 6 objects
[contenants release];
[ingredients release];
[mesures release];

用于交换第一个和第三个数组的代码

- (IBAction) swapUnits { // swap first and third arrays

NSArray *tmp=[self.pickerColumn1 retain];
self.pickerColumn1=self.pickerColumn3;
self.pickerColumn3=tmp;

[tmp release];
// (...)
}

有什么想法吗?谢谢!

丹尼斯

0 个答案:

没有答案