XCode 6 GUI Not Updating - ios

I am using XCode 6 to make a simple calculator using Swift. Anyway, I compiled the code with the initial GUI and it works. However when I change the positioning of some buttons, it does not show up in the compiled app running on iOS simulator. Does anyone know what should be done?
Also, I've changed the code as well, and the code is updated. Ie, pressing button 1 will show 1 in the main textbox, but the interesting thing is the position of the button, which I have changed, still remains in the same position I set it to be initially.

How are you changing the positions of the buttons? If you're doing this by setting frames in code, and your original GUI is laid out in a storyboard, then you're probably fighting against auto layout.
Your storyboard layout will be driven by constraints, which determine the size and position of all the elements of your GUI. Setting a frame manually doesn't change these constraints, so the layout engine resets everything.
Either turn off auto layout (bad idea, since you now have to cope with every screen size manually) or move your buttons by adjusting your constraints.

Related

Auto Layout implementation in already developed app in Xcode 6

I have already developed an IOS app in Objective C, Xcode 6 in which I have disabled the auto layouts and size classes.
Is it now possible to use auto layout after having disabled it earlier?
If yes, how can I implement it? When I enable the auto layouts and size classes and I implement the constraint on the label, the background colour of the label changes to white. When I do this for other object types, they become invisible.
To answer your first question, yes: it is indeed possible to use Auto Layout in an app after having disabled it. Each Xcode project template just gives you an initial starting point – nothing is set in stone.
For the second question, the best way of implementing Auto Layout in an app is to just take it one view at a time. You don't need to go all-or-nothing with Auto Layout; it's possible to just use it in certain cases but use frame based layout in others. Start on smaller, easier views and go from there.
The last issue around background colors is a little trickier without having screenshots or code samples. I have had views disappear on me after implementing Auto Layout and the issue always boiled down to bad constraints. The best solution I can give there is to just do the usual view-debugging work (as in, printing frames and manually setting bright colors to see where views actually are) and figure out what is going wrong.
Having the background color change to white is interesting, though... Auto Layout should not be affecting that at all. It sounds like the background color got changed somehow while the constraints were being created.

Xcode 6 switches being truncated on left (in a table view)

For some reason I cannot get all switches to display properly on a screen. Some of them appear to be overwritten on the left edge but from what I can determine all of the switches and text views are correct. Any suggestions are welcome
So first, to make sure that this is the problem: while your app is running, click on the two rectangles overlapping on the right of the Debug Area to "Debug View Hierarchy"
When you have that, rotate your views to make sure that in every row you don't have your text views overlapping your switches. That's what it looks like what's happening, but you can use this tool to confirm so.
If so, and you are using auto layout, make sure you are setting your constraints correctly. If not, then make sure you are setting the width properly. To prove it's an autolayout issue, you could temporarily hard code a length to every text view to see if the issue is still there. If that fixes it, than auto-layout is just making your textviews wider than they should be.
Good luck!

Designing without auto layout so that it works for every size device

I'm designing an iOS app in Swift, not using auto-layout. I'm not using auto-layout because if i do, when my labels update, the design resets. For now, I'm designing for an iPhone 4.7 inch, but when i run it on the simulator for any other size device, the design is completely messy.
UPDATE:
I designed my storyboard with the proper constraints. I added my UIImages in the override func viewDidLayoutSubviews and positioned them outside of the screen. When a button is tapped, there should be a sequence of animations which are triggered as well as a UILabel which should have its value updated.
I commented out some code and kept running it to find the problem, and I found that the UIView reset whenever the UILabel updated. The values are being queried from Parse.com.
The design works when the label is NOT being updated. But once the value changes, the view resets...
I tried disabling auto-layout and it works. However, if I have auto-layout turned on it doesn't.
What do I do?
Thanks in advance
You should really use Auto Layout. It is the way forward for UI layout. The problem with your labels can surely be fixed with proper constraints.
Make sure you modify constraints instead of frames. The layout engine will calculate the new frames when needed, as helpfully mentioned by #rdelmar.

iOS app only showing half in simulator

I am trying to develop a simple app with one screen for iOS and am running into a strange problem. Only half of the app is showing up. For example I have a screen with just one button in the center of the screen. When I run the app in the simulator I only see half the button and I cannot move it either.I can scroll the view in the simulator vertically but not horizontally. I am stumped. Will appreciate any pointers.
I'm pretty sure you built your view using the main storyboard and put everything in the middle of it. The main storyboard is set to take all iOS format into account, iPhone and iPad. If you want your app to appear centered on your iOS device, you need to constraint the position of your different UI objects, using Auto Layout. That way it would appear centered automatically, whatever is the device you're using
I reckon you've got AutoLayout turned on... but haven't set any constraints on your controls yet.
Try the following test:
Go into your Storyboard file.
Click on a blank area in your storyboard, then on your screen (so the border of your screen is blue - not black or gray).
In the menu bar, click on Editor \ Resolve Auto Layout Issues, and then "Update Frames".
Alternatively, you can click on the following button, and select "Update Frames" from there (it doesn't matter which one):
When you do this, where does your "one button" end up ? Does it suddenly disappear off the screen, have a negative X or Y position, or a width/height of 0 ? If so, then AutoLayout is your problem.
With XCode 6.1, Apple has put a gun to developers' heads and demanded that when you add an object to a Storyboard, you must - straightaway - add some constraints to it.
I had this issue when I first upgraded to XCode 6.
I would add, say, a View to a screen, stretch it to a particular size, then drag a second control (perhaps a Label) onto the same screen. Suddenly, my View would resize itself to a height/width of zero, or be positioned way off the side of the screen... huh ?!
To get around this, when you add a control onto a Storyboard, you must add sufficient constraints to really let XCode calculate where to position it, based on which device/orientation the device is running on. And, yes, you sometimes need to do this straightaway before XCode ridiculously decides to mess up your control's position or size.
I really do loathe XCode. This isn't the way a development environment should behave in 2015...
If I get your point of problem then
I m sure the problem is you have auto layout and size classes enabled.
check if you have Auto layout and size classes enabled ....???
If yes then you haven't set the constraints accurately. set the constraints for the UI Objects to show on your desired position in screen.

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.

Resources