2014-05-17 3 views
1

Salut, je reçois l'erreur: Propriété « editingIndexPath » introuvable sur l'objet de type « ViewController * » avec la ligne:
[self.tableView scrollToRowAtIndexPath:self.editingIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];Contenu Décalage UITableView lorsque le clavier apparaît

L'erreur a quelque chose à voir avec cet appel: self.editingIndexPath

Comment réparer cette erreur?

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(keyboardWillShow:) 
               name:UIKeyboardWillShowNotification 
               object:nil]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(keyboardWillHide:) 
               name:UIKeyboardWillHideNotification 
               object:nil]; 
} 

- (void)keyboardWillShow:(NSNotification *)notification 
{ 
    CGSize keyboardSize = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size; 

    UIEdgeInsets contentInsets; 
    if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) { 
     contentInsets = UIEdgeInsetsMake(0.0, 0.0, (keyboardSize.height), 0.0); 
    } else { 
     contentInsets = UIEdgeInsetsMake(0.0, 0.0, (keyboardSize.width), 0.0); 
    } 

    self.tableView.contentInset = contentInsets; 
    self.tableView.scrollIndicatorInsets = contentInsets; 
    [self.tableView scrollToRowAtIndexPath:self.editingIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; 
} 

- (void)keyboardWillHide:(NSNotification *)notification 
{ 
    self.tableView.contentInset = UIEdgeInsetsZero; 
    self.tableView.scrollIndicatorInsets = UIEdgeInsetsZero; 
} 

Répondre

3

Le compilateur vous dit tout. Définissez simplement une propriété editingIndexPath.

@property(nonatomic, strong) NSIndexPath *editingIndexPath 
+0

En rapide va-t-il fonctionner? –

Questions connexes