Ich habe festgestellt, dass scrollToRowAtIndexPath:atScrollPosition:animated:
nicht zu Zelle scrollt, die derzeit nicht in Sicht sind, also wenn ich 100 Zellen habe und ich an die bei 70, den Anruf an bekomme Dieser Selektor wird nichts tun.scrollToRowAtIndexPath scrollt nicht zu inaktiven/unbelasteten Zellen
Gibt es eine Möglichkeit, diese Zelle in den Speicher zu bekommen? Ich habe bereits den Indexpfad der Zelle ...
Ich muss zu dieser Position in meiner App scrollen, wenn der Benutzer dorthin gehen möchte.
Danke für irgendwelche Gedanken!
EDIT: @dasblinkenlight
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide) name:UIKeyboardWillHideNotification object:nil];
}
- (void)keyboardWillHide
{
//Load remote cell here then scroll
// :(dont know how to load remote cell yet
}
- (void)keyboardWillShow
{
//Load remote cell here then scroll
// :(dont know how to load remote cell yet
//_cellIndexPath gets assigned on didSelectRowAtIndexPath:
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:_cellIndexPath.row inSection:_cellIndexPath.section] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
}
EDIT2:
- (void)keyboardWillShow
{
//Load remote cell here then scroll
[NSThread detachNewThreadSelector:@selector(keyboardWillShowThreaded) toTarget:self withObject:nil];
}
- (void)keyboardWillShowThreaded
{
[NSThread sleepForTimeInterval:2.0];
[self performSelectorOnMainThread:@selector(keyboardWillShowMainThread) withObject:nil waitUntilDone:YES];
}
- (void)keyboardWillShowMainThread
{
//Get the cell
//_textFieldThatHasFirstResponder is a subview in the cell
//This returns null, probably because the cell is not loaded into memory
UITableViewCell *cell = [_textFieldThatHasFirstResponder superview];
NSLog(@"CELL TO SCROLL TO: %@",cell);
NSIndexPath *indexPathForCell = [self.tableView indexPathForCell:cell];
[self.tableView scrollToRowAtIndexPath:indexPathForCell atScrollPosition:UITableViewScrollPositionMiddle animated:YES];
}
Es * sollte * zu einer Zelle scrollen, die sich außerhalb des sichtbaren Bereichs befindet. Können Sie zeigen, wie Sie es anrufen, und von welcher Methode machen Sie diesen Anruf? – dasblinkenlight
Ja, vielleicht hast du recht, aber ich habe meine 8 Zellen sichtbar, und wenn ich zB tippe. der zweite, es scrollt gut, aber wenn ich die 8'te Zelle tappe, die teilweise außer Sichtweite ist, geschieht dies, von der Quelle gibt es viel mehr Zellen, aber nicht sichtbar, die, die unsichtbar sind, scrollen auch nicht. –
Können Sie auch den Teil anzeigen, wo Sie 'scrollToRowAtIndexPath' aufrufen? – dasblinkenlight