iOS 7 setContentOffset in viewDidLoad resettting to 0 - ios

I have a UISearchBar attached to the top of the table view. The idea is that when you drag down from the top you can search.
So under iOS 6 I have attached the search bar and then in the viewDidLoad I "setContentOffset" to CGPointMake( 0, searchBar.frame.size.height ) which sets the content offset to 44.
This works perfectly for me.
However the behaviour is not the same in iOS 7.
After I do the setContentOffset in viewDidLoad, I see an internal call to _notifyDidScroll which sets the content offset back to 0 (after viewDidLoad has completed). The funny thing is my search bar is not at -44.
How can I make iOS6 and iOS7 behave the same way? I don't care if iOS6 starts doing this notifyDidScroll or iOS 7 stops doing it, but i'd like consistency between both versions!
For now I have had to use a horrible solution that performs different tasks on iOS 7 and iOS6.

I think you need to disable UnderTopBars in your ViewController. You can do this in the storyboard or .xib in the property of your UIViewController.
edit:
Hope that will help.

Related

How to control UIScrollView automatically scrolling on FirstResponder / Keyboard changes?

TL;DR
Is it a new feature in Xcode 14 and iOS 16 that a UIScrollView is now scrolled automatically when a view inside the ScrollView becomes firstReponder and the keyboard appears? While working on other iOS projects in earlier versions of Xcode and iOS I never came across this behaviour. Can this be controlled or deactivated?
Details:
While working with Xcode 14.0.1 on a new iOS project I noticed that an UIScrollView is now automatically scrolled when the content view becomes first responder.
Have a look at this example. I have created a new project, added a ScrollView to the ViewController and placed 12 subviews inside to fill it with some content. Subview no. 12 additionally holds a UITextField. The firstResponder status of this text field can be toggled using the top button.
When tapping on the button the TextField becomes firstResponder and the ScrollView is automatically scrolled up. However, not enough to make bring the TextField above the keyboard and make visible. Just enough to bring it above the bottom screen edge.
This does not make a lot of sense to me.
Is it possible to control this automatic scrolling or to deactivate it?
EDIT:
I have created CustomScrollView as UIScrollView subclass and did override scrollRectToVisible. When calling super.scrollRectToVisible everything works as before, but I could set a break point to see from where scrollRectToVisible is called.
The callstack shows the method scrollTextFieldToVisibleIfNecessary inside UITextField which uses delegateShouldScrollToVisibleWhenBecomingFirstResponder
However, UITextFileDelegate does not have such a method / value and scrollTextFieldToVisibleIfNecessary is also documented nowhere.
So, the question remains: How to disable this behaviour?

iOS 11 expanding navbar stops expanding after scroll up

I have implemented two different tableviews. The first uses a UIViewController and a UITableView. The second uses a UITableViewController with static cells.
I currently have prefersLargeTitles = true. On the first view controller, the navbar expands as I drag down the table as expected. However, after I scroll up making the navbar shrink, letting go and pulling down on the table again does not expand the navbar and it seems to be "stuck" after that.
This is not an issue on the second controller that uses a UITableViewController.
This issue does not occur on the simulator, but has occurred on two different iPhone 7's (iOS 11.2 beta 4, iOS 11.1.2)
As you can see below, after I go to scroll back down after scrolling up, there is a slight jolt then it sticks. The navbar no longer expands after this point (it does collapse still).
Here is an example of what should occur and happens with the UITableViewController.
Is this an iOS 11 issue?

iOS 7 have a trouble about layout

My app use uitabbar and uinavigationbar.but I encounter a problem in iOS7.1. if I switch page between one with navigationbar and one without navigationbar. the page have scrollview or uitableview,every time swith,self.view.frame or self.view.bounds is Correct,but scrollview or uitableview's frame is Correct but bounds.y every time swith will change 20px.one up,one down.
i try to change scrollview or uitableview's bounds.y in view will viewWillAppear.
CGRect bounds = contentScrollView.bounds;
bounds.origin = CGPointMake(0, 0);
contentScrollView.bounds = bounds;
but if i do it,ok,every time swith page is show right,but when i drag the scrollview or uitableview,the layout incorrect.
the demo has upload on github:https://github.com/KingCentLee/HSText
I hope someone can help me.the demo in iOS 7 later is normal. just iOS 7 swith page encounter the problem.and can tell the reason.Thank you.
I have seen your code. Try delete the code in viewWillAppear. I'am sorry, I don't have ios7 device. In my memory, it may cause by the system status bar which height is just 20px. This is only a suggestion. ps:I can't add a comment.

iOS 7 tableview no longer auto scrolling when keybaord appears

I am working on an app which I have just released an iOS7 version of. In the app I have a table view that contains text feilds in each cell. The problem is that when I tab to edit a feild that is near the bottom of the screen the keyboard appears and I cant see what I'm typing. I fixed this in iOS6 by simple listening for the event of the keybaord appearing and changing the size of the tableview so that it no longer extended to the bottom of the screen, but instead only reached to the top of they keyboar. The table view would then "automatically" scroll so that the cell was visable. This worked fine in iOS6 but as soon as I made the switch to iOS7 this no longer works... it no longer "automatically scrolls" when I change the size of the table. Does anyone know if there is a property that I need to set or something to "re-enable" this functionality?

Why is my UITableView cut off in iOS 7?

In iOS 6, my login tableview that consisted of two rows (Username and Password) was completely shown correctly. In iOS 7, the bottom row is cut off, and I don't know why or how to correct the issue. Nothing changed except for upgrading to Xcode 5 and running on the iOS 7 simulator.
UPDATE: adding more images
try playing with navigationBar.translucent property in your view controller. in iOS 6 it is NO by default, but YES in iOS 7. I had a similar issue and this fixed it for me.
Just check your UITableView frame in iOS7, may be you are running it on 3.5 inch view and it will shrink.
Looking at the provided image, I think you may be underlapping the nav bar. Or to put it another way, your nav bar is on top of hte table. Though I'm not sure why that would cut off the bottom of the login information
I've found that simply changing from GROUPED to PLAIN table view style fixes the "underlap" issue with the section #0 header, but modifies the color of the section header views. I set the tableview background color in my app. With PLAIN style, the section header background color is messed up. The section header color is close to the tableview background color, but slightly modified. This does NOT happen if I simply switch back to GROUPED. It sounds like an iOS7 bug or an Xcode bug.
The translucent = NO fixed it for some cases. In others, I ended up adjusting the tableView in viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
CGRect f = self.tableView.frame;
f.origin.y += self.navigationController.navigationBar.frame.size.height;
f.size.height -= self.navigationController.navigationBar.frame.size.height;
self.tableView.frame = f;
}
This is obviously some kind of issue with the grouped table view style. All I had to to was go into the storyboard scene, select the table view, then in the attributes inspector change the style from grouped to plain. It works as intended now without being cut off.

Resources