Scrollview not showing textfield - iphone

I have a scrollview with frame (0, 64, 320, 44), i'm trying to add a subview "UITextfield" with frame size of (20, 7, 280, 30), I'm doing everything in storyboard. it looks good, i can see the textfield on top of scrollview However, when i run the project, in simulator, i don't see the textfield, i have to scroll up to see the textfield. i'm not doing any offset, i'm using xCode 5, but when i do the same thing on xCode 4.6, it works like a charm.
Does anyone know if it's an xcode issue or am i doing anything wrong?

Try using
[self setAutomaticallyAdjustsScrollViewInsets:NO];

Related

UIview layout not autosizing for iPhone retina 4 inch screen

Xcode 5 storyboard app.
When I tap on button in the app, choosing a property - UIView opens, but only shows the correct layout for the first View.
When swiping left/right - the layout of all views is fine. The problem only happens when I tap on any button, except the first one. All the settings for all views and all code in .h and .m files are equal.
I use iCarousel for swipes.
Screenshots will help you to understand the problem better:
Right:
![Correct layout]
http://i.stack.imgur.com/b0HEP.jpg
Wrong: (see blank space at the top and bottom)
![Incorrect one - has to look like Pic.1]
http://i.stack.imgur.com/xqTmH.png
I don't want to mess with auto layout because scrollviews doesn't work properly with it. Any help would be appreciated! Thanks!
Check out if this works. I too had a issue of same kind where the position of top and bottom margin has shifted. I used this in viewDidLoad method.
if( [self respondsToSelector:#selector(setEdgesForExtendedLayout:)] )
{
self.edgesForExtendedLayout=UIRectEdgeNone;
}
or else set frame for iPhone retina 4 inch screen like this
if(IS_IPHONE_5)
{
tableView.frame = CGRectMake(0, 0, 320, 560); // something like this in DidLoad method or in viewWillAppear method
}

iPhone / iOS - UIButton not recieving touches when it is lower on view

I have a really strange problem. I have a UIView and on that view I have 3 UIButtons.
the UIView has a frame
CGRectMake(0, 0, 320, 300)
and I put the buttons on the frame one next to the other with height 50 pixels on the bottom part of the UIView but still within it.
For some reason the UIButtons don't receive the touch but if I raise their height they do...
what could be the cause of this strange problem?
maybe there is a component at the same place with the button with a different zindex
try this mothode to bring your btn to front
[yourView bringSubviewToFront:yourButton]
You may also look into the frame size of the UIButton's parent view. when I started out I often overlooked this and actually what happened is the button is not completely inside the parent. But due to the fact the parent view is not clipping that view I could see it... but not interact with part or all of it.
Try changing CGRectMake(0, 0, 320, 300) to CGRectMake(0, 100, 320, 300) or similar to move the view down the page and compare the behaviour with moving the buttons inside the view.
Does this have the same effect as moving the buttons?
This should help you work out if the problem is within this view, or outside of it.

UIView size/position not working on iPad as on iPhone

I have a UIView of size width=320px height=40px which I want to display at the bottom looking like a tab-bar.
I use the following code to accomplish this and it works fine on iPhone. But when I try the iPad simulator, the view does not appear anywhere on the screen.
buttonsView.frame=CGRectMake(
0,
self.view.frame.size.height - buttonsView.frame.size.height,
self.view.frame.size.width,
buttonsView.frame.size.height );
This stretches the view to the width of the screen but keeps it's original height.
How can I make this show right on my iPad also?
[UPDATE]
This happens in my viewDidLoad.
I have this NSLog now:
NSLog(#"buttonsView Width: \t%g\t%g\tHeight:\t%g\t%g",self.view.frame.size.width, buttonsView.frame.size.width, self.view.frame.size.height, buttonsView.frame.size.height);
With output:
iPhone:
buttonsView Width: 320 320 Height: 460 40
iPad:
buttonsView Width: 768 768 Height: 1004 40
I also create another view like this for the top of the page which works fine:
dataView.frame=CGRectMake(
0,
0,
self.view.frame.size.width,
dataView.frame.size.height);
Have you looked (using breakpoints or NSLog) at the values you are putting into the CGRectMake call, just as a sort of "sanity check"?
Thanks for the info. My next thought is that between viewDidLoad and viewWillAppear something is being changed by the OS. Perhaps try moving the code to viewWillAppear so that you are guaranteed the frames you are working with will be the frames that will be displayed. This Stack Overflow answer explains it in a little bit more depth.
This happened because the Auto Resizing was set for the UIView's.
To fix, set the Auto Resizing to bind it to the top left corner. This way whenever you change the frame, it is relative to the top left pixel.

A toolbar is not where it should be

I have an iPhone app. i'm trying to make it universal w/out new xibs. from a UI aspect, my app is fairly simple and straight forward, i just have a a UIImageview and some toolbars.
i'm having an issue where i set my top toolbar to 0, 0 but it is appearing in the middle of my screen when its an iPad.
topToolBar.frame = CGRectMake(0, (-1 * topToolBar.frame.size.height), topToolBar.frame.size.width, topToolBar.frame.size.height);
i initially hide the toolbar and show it if you tap the screen (works properly on iPhone). when i try to set the toolbar hidden on the iPad, its in the middle of the screen. when i nslog the frame, it shows (0, -44, 320, 44) which means it still thinks the screen size is iphone of (480, 320).
the funny part is when i use my tap function to show/hide the toolbar, it behaves properly with a frame of (0, -44, 768, 44).
my hide/show animation block is:
[UIView animateWithDuration:.2
delay:0
options:(UIViewAnimationOptionAllowUserInteraction)
animations:^{
topToolBar.frame = CGRectMake(0, (-1 * topToolBar.frame.size.height), topToolBar.frame.size.width, topToolBar.frame.size.height);
}
completion:nil];
its the same code i use to try to initially hide the toolbar. any ideas what is going on?
I would guess it’s an issue with the toolbar’s autoresizing mask. If you’re creating it in Interface Builder, make sure that the strut on the bottom is grayed out and that the ones on the other three sides are highlighted, like this:
If you’re creating the toolbar programmatically, you can just set its autoresizingMask to UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin.

UIScrollView height adjusts from IB

I've created a UIScrollView in Interface Builder which takes up the entire screen of the iPad (0, 0, 1024, 768)
However - when running the app, the scrollView is only displaying on the screen at (0, 0, 1024, 440). The 440 is an estimate, but it is not extending all the way down to fill the screen as it should.
I've done this same thing in other apps and have not encountered this issue.
I've run "Clean" on the project and I've tried deleting the scrollView and recreating it and still the same issue occurs.
I even tried to programmatically reinforce what's in Interface Builder but still it showed up the same way.
CGRect scrollFrame = CGRectMake(0, 0, 1024, 768);
[scrollView setFrame:scrollFrame];
If you have any idea why this may be happening, your help would be GREATLY appreciated.
* UPDATE *
After some more research, there is something wrong with the view controller.
That area at the bottom where the scrollView isn't showing is totally not accessible. If I put a button toward the bottom of the screen, I can't click that button. If it's up in the top half of the screen I can click it just fine.
Also, the scrollview isn't really starting at 0, 0. Where it starts it is missing the top part of the content. So it seems like the scrollView DOES have the height of 768, but is starting at -320 so that the top of it is off the top of the screen and the bottom of it ends before the bottom of the screen.
The issue seems to have been that the app thought it was in Portrait mode even though I had the .xib in Landscape mode.
Fixed it with this little trick in the viewDidLoad of the mainProjectViewController:
CGRect landFrame = self.view.frame;
landFrame.size.width = self.view.frame.size.height;
landFrame.size.height = self.view.frame.size.width;
self.view.frame = landFrame;
Actually, viewing it in landscape mode is just a convenience for you to see what happens if you rotate the device. Launching in landscape mode can be problematic. See this question and its answers for some excellent info.