J'utilise un PickerView pour choisir des valeurs et je veux le réinitialiser, (il n'affiche donc pas la sélection précédente) après avoir appuyé sur un bouton. Le problème est que je reçois toujours l'une des deux erreurs, elle change d'exécution à exécution sans motif apparent.iOS: Réinitialisation de UIPickerView EXC_BAD_ACCESS Erreur
Est-ce que quelqu'un sait ce qui pourrait causer les erreurs, respectivement comment résoudre le problème? J'apprécierais vraiment l'aide!
code:
NSString * chosen;
NSString * elemString;
NSMutableArray *secondTableArray ;
NSInteger p = 0;
@implementation LagerViewController
@synthesize requestObject;
@synthesize choosenDocKind;
@synthesize pickerView1;
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
secondTableArray = [[NSMutableArray alloc] init];
secondTableView.scrollEnabled = YES;
secondTableView.bounces = YES;
elemString = @"";
choosenDocKind = [[NSString alloc] initWithString:@""];
[pickerView removeFromSuperview];
}
- (void)tableView:(UITableView *)theTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(pickerViewItems != nil)
{
[pickerViewItems release];
pickerViewItems = nil;
}
if((indexPath.section == 1)&&(indexPath.row == 0))
{
NSString * temp = [[NSString stringWithFormat:@"%@",elemString] copy];
NSString * tableString;
if([temp length] == 0) {
[secondTableArray removeAllObjects];
[secondTableView reloadData];
elemString = [[NSString stringWithFormat:@"ARTIKEL: %@ %@ %@", matchcode, quantity, choosenDocKind] copy];
tableString = [[NSString stringWithFormat:@"%@ %@ %@", matchcode, quantity, choosenDocKind] copy];
// THESE 2 ROWS BELOW CAUSE THE ERRORS
[pickerView reloadAllComponents];
[pickerView selectRow:0 inComponent:0 animated:YES];
}
}
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
[theTableView deselectRowAtIndexPath:indexPath animated:YES];
}
#pragma mark - button events
- (IBAction)btnSubmitPVSelection:(id)sender
{
if([choosenPrompt isEqualToString:NSLocalizedString(@"DOCUMENT_REQUEST_LAGER_UM", nil)])
{
if(choosenDocKind != nil)
{
chosen = choosenDocKind;
[choosenDocKind release];
choosenDocKind = nil;
}
choosenDocKind = [[[NSString alloc] initWithString:[pickerViewItems objectAtIndex:[pickerView selectedRowInComponent:0]]] retain];
}
[tvArchDocParam reloadData];
if(choosenPrompt != nil)
{
[self.presentedViewController dismissViewControllerAnimated:NO completion:nil];
[choosenPrompt release];
choosenPrompt = nil;
}
[pickerView reloadAllComponents];
[pickerView selectRow:0 inComponent:0 animated:YES];
}
.h
@interface ... {
DocRequest *requestObject;
NSArray *pickerViewItems;
NSString *choosenPrompt;
UITextView *matchtext;
IBOutlet UITableView *tvArchDocParam;
UIAlertController *actionSheet;
UITableView *theTableView;
IBOutlet UITableView *secondTableView;
}
@property (nonatomic, retain)DocRequest* requestObject;
@property (nonatomic, retain)UIPickerView *pickerView1;
-(UITableViewCell*)getSelectorCell:(NSString*)CellIdentifier;
-(UITableViewCell*)getTextFieldCell:(NSString*)CellIdentifier;
-(void)showPickerView;
Erreurs:
1. Thread 1: EXC_BAD_ACCESS
2. Terminating app due to uncaught exception 'NSInvalidArgumentException', reason NSDictionaryM reloadAllComponents
Comment déclarez-vous pickerView et où le créez-vous? –
montre comment vous déclarez toutes les variables et les méthodes UIPickerViewDataSource –
une fois de plus - montrez comment vous créez pickerView1 et où l'affichez/cachez-vous. montrez par exemple ce que vous faites dans - (UIView *) pickerView: (UIPickerView *) pickerView viewForRow: (NSInteger) ligne forComponent: composant (NSInteger) réutilingView: (vue UIView *). Certanly raison de votre accident est dans la gestion de memort, probablement à cause de pickerView ou quelque chose de lié à montrer des éléments en elle. Donc, plus vous montrer à ce sujet - plus je peux vous dire à propos de l'accident –