Constraint broke UIButton on iPhone - ios

I have a universal app using auto layout, but for unknown reason, the constraint I have on the UIButton is causing the button to not respond on iPhone (works perfectly fine on iPad). Below is the snapshot of my .xib view that will eventually get embedded inside another UIScrollView.
Note that "(read drug facts...)" is my standard UIButton that doesn't respond to click on iPhone. However, when I changed the top spacing between Dose label and Body View, then it responded to clicks. But, when I reduced the spacing constant from 40 down to 10 then the button won't respond anymore. I don't see view that is invisibly hiding the button.
UPDATE 1:
Thanks Matt for reminding me of the great view debugging feature which I've forgotten about. Even with the view debugging, I'm unable to find its culprit. Please see images below.

Related

after resizing view size, no response for tapping UIswitch, UIstepper, UIbutton in both similator and actual device

I have a subview and a tableviewcontroller inside a view. Please see attached pics. My view on top was like 12 points larger so I resized it and adjusted the y position of bottom tableviewcontroller also accordingly so they both align. after this change, only UISegmentedControl (delivery/takeout) is responding to tap on both simulator and device. Rest of them are not responding at all. I do not have any UITapGestureRecognizer code in the viewcontroller.m file. Am using xcode 11.7.
I tried removing all connections and added them again. tried removing all directories under "Library/Application\ Support/iPhone\ Simulator/7.1/Applications/". Reset the simulator. Tried tapping controls with "option" key pressed. Tried pressing in several places of view on top. nothing seems to help. What could be going on. there are no layout warnings in Console output. thank you.

Interface Builder strange interface error

I am having a strange error on my builds. When i design my view in interface builder, everything looks fine. As soon as I run my app on my iPhone, everything messes up. The buttons I use are smushed into the top left corner of the screen, and the font size does not change, even though I have proper settings for all screen sizes. The labels A and B work fine though. This is very puzzling to me. This is not the only view which I am having this error with. Here are pictures to detail my problem further:
This is the view I see in interface builder.
The view I see when I run my app on my phone is quite different.
Why am I seeing the views so differently? Why are the buttons being smushed to the top right of the screen when I run my app?
You probably don't have sufficient constraints on those buttons for the runtime to know how to place them. Usually constraint issues will show up at build/design time with a yellow or red circle in the tree view for the storyboard/xib. Try using "reset to suggested constraints"

Why does my button stop working when it is placed too low on my view controller?

I have an app that works fine on a 4 inch iPhone. However, when I test the app on the 3.5 inch iPhone, my buttons near the bottom of the view don't work anymore. I have buttons higher up that are still working fine. I tested this out on the 4 inch simulator - when I put a button even closer to the bottom, it wouldn't work. By not working, I mean they are no longer clickable.
Is there something thats stopping me from operating too low on a view? I currently use a container view with a scroll view which points to my view controller.
Hard to tell.
If you are working with Interface Builder, you can't even show us what's your setup. This doesn't help
My first guess is that you either have an invisible element on top of your buttons, or that something funny is happening with the content view of your scroll view.
Try to place your buttons directly in the parent/root view. If that works, bring them back to their original position in the view hierarchy, one level at a time. This should give you an idea of where they stop working, and what might be causing it.

IOS - How to get my text view object information to scroll on view?

I am using Mac OS X Lion 10.7.5 and XCode Version 4.6.1 (4H512),
I have looked at these answers on stackoverflow to try to figure out my question
-cannot make a text view scroll - xcode 4.3
-also posts that looked possible, when I searched on "scroll text in UITextView" within stackoverflow
Within Interface Builder I cannot figure out how to make information in a UiTextView object scroll within the iPhone simulator*. To resolve this challenge, I have made the most simple prototype project I can think of, just a view and one text view object on it, filling the text view object with a stream of text simply typed in via interface builder. For this most basic sample I'm using to sort out my problem, I have not done anything programatic. (Please note that I am aware of StoryBoards and have begun working through a book to learn to use them, but I would like to finish my first prototype app using what I’ve already learned and fully complete one project before I move onto my next project using StoryBoards.)
When I run this in the iPhone simulator, I see the sample information in my text view object come up. As I expected not all the information displays, due to my sizing the box a little too small on purpose. But I cannot flick or arrow down, or in any other way view the rest of the text information within the simulator. Nor do I see scrolling bars anywhere on the view. The information is just frozen in/on the view.
Inspector Settings
Identity Inspector
"Accessibility" Tested both with Enabled checked and not checked
Use Auto Layout is NOT checked
Attributes Inspector
Behavior Editable box not checked
Scroll View Area Checked ‘show horizontal scrollers, shows vertical scrollers and also scrolling enabled” The rest of the scrollers box are not checked
Bounces is checked
Zoom min and max are both 1
Touch all boxes checked- bounces zoom, delays content touches, cancellable content touches
View mode is ‘scale to fill”
Interaction ‘multiple touch’ is checked
Drawing checked opaque, clears graphics context, clip subviews, and autoresize subviews. Only ‘hidden’ is not checked
Size Inspector
I played around with the ‘scrolling insets’ boxes changing them from the default (I think it was 0 or 1), just to see if I noticed anything. I think maybe that I see some shadowy marker type lines in Interface builder in the area where I might expect a scroll bar when I make these changes, but no change in appearance within the simulator.
I cannot figure out why my actual iPhone device with everything up to date, is now not working as a test device, but I believe that is a separate challenge
how about wrapping you uitextfield in a uiscrollview. Make the scroll view the dimensions you currently are setting the uitextfield to, then allow your uitextfield to scale to the size of the text.
This is one of those questions that solved itself eventually. After twice creating the most basic app, with no programmatic bits just interface builder and a textView object with all the defaults the scrolling worked. The only reason I can think of that it might not have scrolled as expected the first time through may have had to do with placement of the textView object on the view. I wonder if it overlapped the bottom of the view and maybe that messes something up.
Just one of those situations where I had to keep plugging away, trying what seemed like the same thing repeatedly,set in the Inspectors, and suddenly, like magic, it worked. Except no magic involved.

Using UIScrollview in iphone5 compatible app

I have a problem adapting my apps to the new iphone5 layout, I've made the following passes:
Added a retina 4" splash image
Modified the interface in my storyboard with "Size inspector" to change the anchoring of the widgets
Tested the app with iOS6 "retina 4" simulator.
The app works as expected except when the user pop up the keyboard to edit a text, I use the "stretching scrollview" method for this particular situation and this seems not compatibile with the "autosizing" properties of my widgets, here is an example, from iOS6 simulator, without and with keyboard:
And here is what happens:
I'm quite sure this is a coherent behaviour since my main view is stretched so the other items inside it are stretched following their anchoring, the fact is that I'd like to have the same behaviour of my previous fixed position (all widgets anchored to the top left corner) with the iphone5 gui expansion, is this possibile?
How do you solve the problem of showing a keyboard and scroll hidden content in an iphone 5 compatible way?
I have been having similar problems. From what I have found thus far, we may need to remove all constraints on the view within the scrollable view, because it appears that it's contents are being resized along with the frame of the scrollView. I know that setting the internal view's frame manually in viewWillAppear will work, but then you are stuck having a view that is the same size for both iPhone4 and iPhone5 (albeit it will scroll). Or you could "pin height and pin width" of the internalView right there in storyboard.
Two potential approaches that may work. Sorry I can't confirm these as I'm giving up and redesigning around this problem.
1. Programmatically add constraints to your internal view's subviews. The programmatic constraints will allow you to "spring" the distance between your elements proportionally. When adding constraints programmatically, you are given access to a factor called "multiplier" (not to be confused with priority), which I saw someone else on stackoverflow posting about.
2. You can design the internalView in Interface Builder as a separate viewController with it's .xib file, and then use storyboard to load it as an embedded viewController to a "containerView" object, which you would put in place as the new "internal view" of the scrollView. Perhaps then the .xib would first resize to the correct iOS device, and then you could use its frame to resize the containerView.
My advice is create a small test-case of these before implementing, else you end up like me, having spent hours down the wrong path and facing a dead-end.
UPDATE 12/4/12
Make your life easier by NOT setting the ScrollView as the main view of the ViewController.
--Instead, make ViewController.view a dummy/blank view, and embed a scrollView inside that view. Then, embed another view (my CustomView) in the ScrollView. CustomView contains all the visible controls and text boxes and buttons. There is NO HEIGHT CONSTRAINT on CustomView.

Resources