I have used to set something on statusbar position and I removed it. But now, I want to set the statusbar into clearcolor. And there was a view appeared. I checked the code already, there is nothing about the statusbar in my code. How to remove this view?
- [2] : <UIView: 0x1014ecaf0; frame = (0 0; 414 20); tag = 100; layer = <CALayer: 0x17442ddc0>>
I printed the view's subviews, I don't know who create this view. And this view make the problem.
It's likely that your top view in Interface Builder is arranged to the Top Layout Guide. If you want it to be somewhat overlapped by the Status Bar, so the Status Bar lie on it and use its color as backroung, you need set your top constaint to be arranged with the superview, not the the Top Layout Guide.
Please check this answer for more details.
I think i find the wrong in my code.I'm so sorry.I used my teammate's tool class,he create a view cover the status bar to solve his problem.In some special condition that view didn't exist.So i find it for a long time.Sorry about that.
But i still learn a lot.Thank all you guys.
Related
I'm using auto layouts and custom layout for my collection view. There were a lot of auto layout warnings initially but I managed to remove all those warnings. Now the views are laid out fine but one of the subviews (a UIButton) of my collection view's cell is behaving weirdly. I have to make this button circular by setting its layer's cornerRadius based on the new frame of the button. Here's the code:
The frame of this button on storyboard is (8, 6, 52, 52). The debugger output looks something like this:
You can see that the corner radius of the button's layer is being set to half the height of the button but the resulting view is not what I expect it to be.
The left grey icon is the view I'm talking about. One can see that it is not circular despite having the corner radius set to half its height.
I have been trying and looking around for a solution for quite a while now. Any help would be appreciated.
Thanks
Doing some diagnostics (see the chat session), we confirmed that the issue was not in the view hierarchy nor the cornerRadius nor anything like that, but a simple border in the underlying image.
I've got the issue where my iOS6 app's UI overlaps with the status bar on iOS 7. I've read previous posting on here regarding how to fix this but I'm not getting results.
I have several views all contained within a view controller's main view:
Posted solutions to the status bar overlap issue suggest to add 20 to the Y origin and set a value of -20 to the delta Y to compensate.
The first issue is I can't set the origin in IB for my main high level view - its greyed out:
So instead in the VC's viewDidLoad a tried setting the origin manually:
- (void)viewDidLoad
{
CGRect frame = self.view.frame;
frame.origin.y = 20;
self.view.frame = frame;
However when I run the app there's no difference, I'm still getting the status bar overlapping.
I'm only making changes to the main view, as all the other views are children of the main view I was assuming if I adjust just that one everything else will shift relative to that.
How come I'm not seeing any difference after making a change to the origin?
try this combined with your proposed solution in viewDidLoad:
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone;
Another thing you can try is setting the frame on viewdidappear if this does not work for you.
Good luck and upvote up if this works for you :)
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.
I'm creating a view controller that uses a web view which slides behind the navigation bar and status bar. To do this, I'm setting the webView.scrollView.contentInset property to have a top inset of 64.
However, this doesn't shrink the amount of area the web view wants to take up, so if a page is less than a screenful, it has 64 px of white space at the bottom to scroll through. The web views are in a vertical UIPageViewController, so this disrupts paging. Is there some way to get rid of this extra space?
Have you tried something like adjusting the webview's scrollview content insets? Example:
webView.scrollView.contentInset = UIEdgeInsetsMake(0, 0,64, 0)
It sounds like what you need is to adjust the webView.scrollView.contentSize and adjust the height by 64. You may need to provide more information about how it slides behind the nav bar and status bar to help me answer this. I would take a look at this section of the Scroll View Programming Guide:
http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/CreatingBasicScrollViews/CreatingBasicScrollViews.html
Change the clipsToBounds.
webView.clipsToBounds = NO;
This will make its content visible outside its frame, so set its frame like normal, right under the navigation bar. The navigation bar will be translucent and you will see its content under it.
Don't forget to disable Autolayout for the web view!
I've sort of made an end-run around this problem by disabling scrolling on short pages. Basically, I use -stringByEvaluatingJavaScriptFromString: to run some JavaScript inside the page that walks down from document.body and computes the position of the bottom of the bottommost element. (document.body itself is always at least as large as the viewport, so I can't look at its size.) Then, back in Objective-C-land, I compare that to the height of the web view (less the inset), and if it's less, I disable scrolling. This is not a perfect solution, but it covers the worst symptoms.
If someone can come up with a better solution than this, I'd love to hear about it! Either way, I can't award the bounty to myself, so someone will be getting it.
I am newbie for iOS development. What I have done so far is as below.
Created New Project
Removed all controller and added View Controller.
Dragged ScrollView in ViewController
Dragged Tab Bar in ScrollView
Dragged 7 Tab Bar Item in Tab Bar.
Now when I execute this project, I have all 7 tabs on screen which is not looking good. So what I am planning is display only 4 tab at first and if user scroll it horizontally, user can scroll and see rest tabs.
So, what I want to achieve is programmatically set some parameter in ScrollView that it will display only first 4 options only.
Any idea/ suggestion on this to be done?
EDIT :
I think this one may be even more adapted to the situation. Contrary to KLHorizontalSelect, it's kind of old (no commit on the master branch for a year ?) and I have no experience with it, but it may solve your problem : InfiniTabBar.
The description is short :
A scrolling tab bar with space for infinite items
Maybe you can take a look at this control : KLHorizontalSelect.
Here's how it looks like :
I don't think it looks exactly as you want, but I think it works almost as what you're expecting. Maybe you can work on the design ?
You have no code used so far, but you'll absolutely have to do that to achieve this. I'll get you started:
Create a scrollview at the bottom of your viewcontroller. Create UIViews on it and make them have a width of 640 (iPhone Retina screen width). You can put a image and a title on the UIView and make them function as a button. Set the content size to 640/4 *7 and there you go. You can give the background of the scrollview the same image as the UITabBar, but you'll need this.
This snippet might help you:
for (int i = 0; i<7; i++){
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0 + 50*i,0, 50,50);
[scrollView addSubview:view];
}
You'll have to multiply the x origin with the width of the UIViews (plus some margin) to make sure they aren't all on the same spot.