UITableView section index not able to scroll to search bar index
Tag : ios , By : user183676
Date : March 29 2020, 07:55 AM
may help you . To solve this we adjusted the content offset to account for the UITableView's content inset introduced in iOS 7: CGPointMake(0.0, -tableView.contentInset.top) - (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
NSInteger resultIndex = [self getSectionForSectionIndex:index];
// if magnifying glass
if (resultIndex == NSNotFound) {
[tableView setContentOffset:CGPointMake(0.0, -tableView.contentInset.top)];
return NSNotFound;
}
else {
return resultIndex;
}
}
|
iOS: Section overlaps UITableView record
Date : March 29 2020, 07:55 AM
To fix the issue you can do I am trying to display three sections (@"Accounts and Tasks", @"Life Events", @"More") and relevant content in an UITableView. I am creating a custom UILabel for each row and try to display text. - (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
....
UILabel *label;
if(cell == nil) {
label = [[UILabel alloc] initWithFrame:CGRectMake(26, 4, 250, 30)];
label.tag = 8888;
label.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:label];
}
label = (UILabel *)[cell.contentView viewWithTag:8888];
label.text = [listData objectAtIndex:[indexPath row]];
}
|
UISearchController: Section Index of UITableView overlaps searchBar
Date : March 29 2020, 07:55 AM
will help you Finally came up with an acceptable solution to this question. This answer builds off of my question above (I'm using all the same code minus what is changed here). The main thing to note here is that @andrewbuilder was right - adding the search bar as a table header view will guarantee that the search bar will move on scroll; it's just acting like any other table header view. What I ended up doing was a combination of things. The main change I made in my approach was changing the way my main controller presents my search controller. Specifically, I went from self.definesPresentationContext = YES; to self.definesPresentationContext = NO; self.searchBar = self.searchController.searchBar;
[self.view addSubview:self.searchBar];
|
UITableView, Search Bar and section index
Date : March 29 2020, 07:55 AM
this will help I don't know if this is the easiest way to achieve this, but it works. The first thing would be to not add the search bar as a header view, but rather to have it and a table view added to a separate scroll view. Something like this (margins for ilustratory purposes only) : light blue is the underlying scroll view class InnerScrollView: UIScrollView {
func gestureRecognizer(gestureRecognizer: UIGestureRecognizer,
shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
return true
}
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let initalContentOffset = CGPoint(x: 0, y:self.tableView.frame.origin.y)
self.underlyingScrollView.contentOffset = initalContentOffset
}
|
Date : March 29 2020, 07:55 AM
|