Skip to content

Commit eef8ec7

Browse files
committed
Scroll the tableview to show newly-added tokens
1 parent a8035e2 commit eef8ec7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Authenticator/Classes/OTPTokenListViewController.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ - (void)tokenSource:(id)tokenSource didCreateToken:(OTPToken *)token
208208
if ([self.tokenManager addToken:token]) {
209209
[self.tableView reloadData];
210210
[self update];
211+
212+
// Scroll to the new token (added at the bottom)
213+
NSInteger section = [self numberOfSectionsInTableView:self.tableView] - 1;
214+
NSInteger row = [self tableView:self.tableView numberOfRowsInSection:section] - 1;
215+
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:row inSection:section]
216+
atScrollPosition:UITableViewScrollPositionMiddle
217+
animated:YES];
211218
}
212219
}
213220

0 commit comments

Comments
 (0)