我有一個UIDatepicker
它在iOS7中隨機崩潰。在模擬器上,UIDatepicker
完美工作,但在真實設備上總是崩潰。錯誤是EXC_BAD_ADRESS
,但Xcode並沒有給我更多的信息。ios datepicker隨機崩潰
請幫幫我!
我的代碼是:
VistaRuedaViewController.h
@interface VistaRuedaViewController : UIViewController <UITableViewDataSource, UITableViewDelegate,UITabBarControllerDelegate, UITabBarDelegate>
{
NSString *fecha;
Utilidades *util;
BOOL conexion;
UIDatePicker *datePicker;
}
@property (nonatomic, retain) IBOutlet UIButton *button;
@property (nonatomic, retain) IBOutlet UITableView *table;
@property (nonatomic, strong) IBOutlet UIDatePicker *datePicker;
@property (nonatomic, retain) IBOutlet UILabel *labelAviso;
@property (nonatomic, retain) IBOutlet UITabBar *tabbar;
-(IBAction)SelectSend:(id)sender;
@end
VistaRuedaViewController.m
- (void)viewDidLoad
{
...
datePicker = [[UIDatePicker alloc]init];
[datePicker setDate:[NSDate date]];
self.datePicker.minimumDate = [NSDate date];
datePicker.datePickerMode = UIDatePickerModeDate;
...
}
-(IBAction)SelectSend:(id)sender{
UIDatePicker *dp = (UIDatePicker *) sender;
//[table reloadData];
NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
[formatter setLocale:[NSLocale currentLocale]];
[formatter setDateFormat:@"dd/MM/yyyy"];
fecha =[formatter stringFromDate:dp.date];
NSLog(@"FECHA DATAPICKER: %@", dp.date);
NSString *idioma;
NSString *currentL = [Global sharedMySingleton].test;
if([currentL isEqualToString:@"ca-ES"]){
idioma = @"ca";
}
else
{
idioma = currentL;
}
button.enabled = NO;
NSString *PlaningURLString = [NSString stringWithFormat:@"%@%@/PlaningHorario", NSLocalizedString(@"protocolo", @""), NSLocalizedString(@"servidor", @"")];
util = [[Utilidades alloc]init];
conexion = [util testInternetConnection];
if (conexion) {
Planing_pasarela *cargaPlaning = [[Planing_pasarela alloc] init];
[cargaPlaning NSURLConnectionFunction:PlaningURLString:fecha:fecha:idioma];
int ret =[cargaPlaning comprobarFlag];
button.enabled = YES;
if (ret==1) {
[table reloadData];
NSLog(@"DATAPICKER: %@", fecha);
}else{
// Usuario y token incorrectos
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:AMLocalizedString(@"logoutAlert", @"") message:AMLocalizedString(@"logout", @"") delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
alert.tag = 1;
[alert show];
}
}
}
感謝您提前。
在哪一行'壞access'? –
我不知道該行,Xcode只顯示了我:EXC_BAD_ACCESS(code = 1,address = 0xa00000004) – amurcia
添加一個異常斷點。這可能會幫助您顯示發生崩潰的確切位置。 – Abhinit