UIRefreshControl adds strange inset by default - ios

I'm adding a UIRefreshControl to a pretty default UITableView by doing...
iOS SDK 8.1
self being an instance of UITableViewController
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.backgroundColor = [UIColor flatPeterRiverColor];
refreshControl.tintColor = [UIColor whiteColor];
[refreshControl addTarget:self
action:#selector(triggerSync)
forControlEvents:UIControlEventValueChanged];
[self setRefreshControl:refreshControl];
What happens is the following:
There is a strange top inset which I've never set up and which only appears when the UIRefreshControl has been set. Has anyone experienced this before? I'm pretty sure it worked well that way in with iOS 7.0.

Old topic, I don't know if you're still experiencing it but for those who wonder how to fix it I found out a quick solution.
You just have to set height for header in section.
I tried first with 0 but it gave no result.
So I set it to 1.0 for all section and it worked.
Hope this help

Related

UITableView adjust content inset not unitl 1st scroll

while trying to create a tableview with a searchBar I encountered the problem that my tableView automatically adjust the contentInset, but not until the 1st scroll. On another tableView, where is no searchBar the problem does not exists. The setup of the searchController is pretty much ripped out of Apples TableSearchWithUISearchController sample.
So my Codes get called by the TableViewController in viewDidLoad:
resultsController = [[ResultConstantTVController alloc] init];
searchController = [[BaseSearchController alloc] initWithSearchResultsController:resultsController];
searchController.searchResultsUpdater = self;
searchController.delegate = self;
self.navigationItem.searchController = searchController;
self.navigationItem.hidesSearchBarWhenScrolling = NO;
[self.searchBar setBarStyle:UIBarStyleBlackTranslucent];
[self.searchBar setKeyboardAppearance:UIKeyboardAppearanceDark];
[self.searchBar setAutocapitalizationType:UITextAutocapitalizationTypeNone];
self.definesPresentationContext = YES;
self.dimsBackgroundDuringPresentation = NO;
I tried already to set the tableViews contentInsetAdjustmentBehavior to automatic manually but it still won't take effect until the 1st scroll.
Before firstScroll
After first scroll
P.S. I am using the beta Version of Xcode, macOS and iOS.
UPDATE:
I managed to bypass the problem by calling
[self.navigationController.view layoutSubviews];
in viewDidAppear in the TableViewController.
I tried already to set the tableViews contentInsetAdjustmentBehavior to automatic
That was right, but not quite enough. Problems of this sort are usually solved by also setting the table view's alwaysBounceVertical to YES. You need to do this very early in the life of the view controller.

UIRefreshControl wrong size on UITableView/UICollectionView

I'm trying to use a UIRefreshControl that has a colored background. I found that the UIRefreshControl's size is actually inaccurate when you use it on a UITableView or UICollectionView.
To highlight this, I set a background color to the UIRefreshControl and to the cells.
How do I fix this gap? This is driving me nuts. It looks very unprofessional and seems to be hidden with people using white UIRefreshControls.
Here the UIRefreshControl is flush against the UITableView
Now we start to see a little bit of a gap
Now the gap is much bigger
To reproduce this, simply have a plain Storyboard with a UITableViewController.
Relevant code:
self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl setBackgroundColor:[UIColor redColor]];
self.refreshControl.tintColor = [UIColor clearColor];
Repo with code:
https://github.com/Lyricalpanda/RefreshControl/tree/master/RefreshControl
Well, in your sample app, I can make that white gap go away by saying:
self.view.backgroundColor = [UIColor redColor];
But if that's acceptable you don't need to set the refresh control's background color at all just the view's.

InAppSettingsKit Strange cell content allignment after iOS9 update

I use InAppSettingsKit in my projects. And everything was good befor iOS 9 update. I hadn't this problem in iOS 8. It still work but now cell alignment looks strange. Now cell content has strange offset from the left and right sides.
I've downloaded the sample project and found interesting moment. And edited one cell configuration cell. So in fact cell is green, contentView is red.
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:kIASKPSToggleSwitchSpecifier];
cell.accessoryView = [[IASKSwitch alloc] initWithFrame:CGRectMake(0, 0, 79, 27)];
cell.contentView.autoresizingMask |= UIViewAutoresizingFlexibleWidth;
cell.contentView.backgroundColor = [UIColor redColor];
cell.backgroundColor = [UIColor greenColor];
[((IASKSwitch*)cell.accessoryView) addTarget:self action:#selector(toggledValue:) forControlEvents:UIControlEventValueChanged];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
When controller configuring form xib it works good.
Configuration:
Result:
So... Normal left and right offsets. Have no any problems. But! after programmatically push.
- (IBAction)showSettingsPush:(id)sender {
[self.navigationController pushViewController:[[IASKAppSettingsViewController alloc] init] animated:YES];
}
I have this strange result(The same problem in my app):
InAppSettingsKit Source
P.S. Any way thanks for your attention. I would be grateful for any help.
This is actually an iOS 9 feature (cellLayoutMarginsFollowReadableWidth) that limits cells to a good readable width. And IMO your second screenshot looks better. (On a sidenote: in your first shot the section titles are incorrectly aligned - not sure what's the reason for this, works fine in the sample app here).
There's a pull request that allows you to disable this property (default is YES): https://github.com/futuretap/InAppSettingsKit/pull/317
I'll look into potential side effects and might merge this at some time.

Styling separator of table view cells

I have the following code in my willDisplayCell function
//bottom border
UIView* bottomBorderView = [[UIView alloc] initWithFrame:CGRectMake(0, cell.frame.size.height-1, cell.frame.size.width, 1)];/// change size as you need.
bottomBorderView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"dot.png"]];// you can also put image here
[cell.contentView addSubview:bottomBorderView];
It worked just fine in iOS7, but ever since I updated Xcode and started testing the app on iOS8 the borders have been displaying incorrectly. I cant figure out what changed that is causing the issue. The problem seems to get worse the more you scroll.

UISearchBar changes its superview when it is added to UITableViewCell on iOS 7.1

In my project i need an UISearchBar to scroll on an UITableView. So i just put it on an UITableViewCell like this:
searchBar = [[SearchBar alloc] initWithFrame:cell.bounds];
searchBar.delegate = self;
searchBar.placeholder = NSLocalizedString(#"Search friends", "");
searchBar.layer.borderWidth = 1.f;
searchBar.layer.borderColor = [UIColor whiteColor].CGColor;
sdc = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:nil];
sdc.delegate = self;
[cell addSubview:searchBar];
and it works fine on iOS 6. But on iOS 7 it switches to another superview (and literally disappears from the screen) when just getting in focus. At first i thought it's something wrong with my project which causes such a behaviour but then i created a simple test project and i verified this - indeed, it's a rule, on iOS 7.1 UISearchBar added to UITableViewCell moves to another superview and gets lost from the screen right after becoming first responder.
I have overridden willMoveToSuperview: method on the search bar and i see that it moves from UITableViewCellScrollView to a view which class is UIView and whose superview's class is UISearchDisplayControllerContainerView.
After few hours of search and experiments i'm not able to figure out what causes this behaviour and how to escape it. All i know for sure is that it happens right between calls to these two UISearchDisplayDelegate methods: searchDisplayControllerWillBeginSearch: and searchDisplayControllerDidBeginSearch:.
Did anyone ever encountered this? Any ideas how to resolve it?
Are you sure you need this bizarre way to add UISearchBar to UITableViewCell to just scroll it? I simply use smthng like this:
UISearchBar *mainSearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
mainSearchBar.delegate = self;
UISearchDisplayController *searchCon = [[UISearchDisplayController alloc] initWithSearchBar:mainSearchBar contentsController:self ];
searchCon.delegate = self;
searchCon.searchResultsDataSource = self;
searchCon.searchResultsDelegate = self;
mainTableView.tableHeaderView = mainSearchBar;

Resources