iOS 7 have a trouble about layout - ios

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.

Related

UISearchBar hides out in iOS 8

I've been stuck on this issue for some days and couldn't figure out a solution.
Background:
I were rebuilding a code which built on XCode 4 to XCode 6 for making it compatible for iOS 7 and 8. On doing so, I found a weird problem as described in title, the UISearchbar gots invisible when tapping searchbar.
Since the codebase I'm working on is very large, I decided to reproduce this in a sample application and posting the details of sample app here.
As like in this image attached, UISearchBar is inside a UIView contained in a UITableView.
On tapping searchbar, it gets transitioned to some other location on left as like this.
PS: I couldn't take searchbar out of view and place it in tableview as it is creating some other issues in navigation. So please provide a solution which can make the searchbar positioned to its parent view itself.
Thanks in Advance.
Explicitly setting frame for UISearchBar on iOS8 solved the issue for me.
CGSize screenSize = [UIScreen mainScreen].bounds.size;
self.searchController.searchBar.frame = CGRectMake(0.0, 0.0, screenSize.width, 44);

On orientation change touch events recognized for half the screen(portrait width)

I have a PageViewController which handles the gestures so I have not done anything with it. I disabled auto-layout in my storyboard so that I could use autoresize to fill the screen with views.
I have a tabbar and if I reload the page with the tabbaritem. The gesture are working.
How can I make the touch/gesture handler resize on orientation change?
http://kevindew.me/post/18579273258/where-to-progmatically-lay-out-views-in-ios-5-and
In the above link you will find usefull information about laying out and handling orientation changes. Also I had this problem once on a device with lower iOS version if your version can be updated you can try that however it's not a fix. I recommend to check the link and see if your views are properly layed out.

iOS 7 setContentOffset in viewDidLoad resettting to 0

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.

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.

ios7 all searchviews and tableviews off by 20 pixels

EDIT: This is not an issue with the frame. The frame is in the correct spot. It is the content that is off. Yes, we are compensating for clear status bar. ViewDidLoad shows content offset is at 0,0.
On every page of my applcation that has a scrollview it's content is pushed down by 20 pixels. I think it may have something to do with the new StatusBar, or lack thereof. The bug also seems to be present in the simulators settings menu. Screenshot below. This only seems to affect the first scroll view that is added to a ViewController and only if no other views have been added to it. Table views are also being affected because they inherit from Scroll view. To be clear the scrollview starts at the correct origin but the content is pushed down by 20 pixels. This is bizarre because I would think if it was a status bar issue it would be 20 pixels above not below.
Currently we are fixing it by adding this to our base view controller
UIView *hackView = [[UIView alloc] init];
hackView.frame = CGRectMake(0, 0, 0, 0);
[self.view addSubview:hackView];
Obviously, this is a hack.
The same thing is happening on phone and in simulator even with the Gold Member version of IOS7 when building for latest IOS7. You can even see an example of the bug in the simulator's settings tableview and also in ours below.
This is a screenshot immediately after it loads. One bizarre thing that we noticed is that when we execute a pull to refresh it will correct the scrollview and rest at it's correct location. Alternatively, if we compensate it will look correct in the beginning but any subsequent pull to refreshes will migrate the scrollview to -20px
After further testing in Xcode, my original workaround still works, but the real culprit seems to be a Navigation Controller combined with the Adjust Scroll View Insets flag on the view controller. Disabling that solved the issue.
[self setAutomaticallyAdjustsScrollViewInsets:NO];
Original workaround: Try reordering your view hierarchy or add an empty view at the top.
This happened to me, and it appears that when a UIScrollView or similar subclass is first in the hierarchy it gets offset by 20 pixels (to keep it from hitting the status bar). However, this still occurs even when the view in question is nowhere near the top.
This is reproducible in Interface Builder, and an easy workaround for me has been to reorder my views so that a label or button is first under the view controller's view. If that's not possible in your case, adding an empty view (even off screen) above your scrollview also seems to solve the problem.
I added this to my UIViewControllers in viewDidLoad: which were affected and it fixed the issue for me:
NSComparisonResult order = [[UIDevice currentDevice].systemVersion compare: #"7.0" options: NSNumericSearch];
if (order == NSOrderedSame || order == NSOrderedDescending)
{
// OS version >= 7.0
self.edgesForExtendedLayout = UIRectEdgeNone;
}
Another, cleaner method:
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
How are you laying out your views? With autolayout you can use the topLayoutGuide, which should accommodate for these offsets.
In the Ios 7 the view starts from the window from y= 0, move your view to 20 pixel dowm
self.view.frame = CGRectmake (0,20,320,hight);
this is due to transparent status bar in iOS 7.
pull down the view to show it properly.

Resources