Xcode Rotations, AutoLayouts - swift

I'm learning OOP and I'm using Xcode with Swift. I'm learning using a book of Apress, but I don't understand a simple step. The instructions says this:
"Hold down the Shift key and select Top Space To Layout Guide and
Center Horizontally in container in the pop-up, and then press
return."
But the pop-up doesn't appear. Can someone help me please?

You can set the constraints in multiple ways within the Interface Builder.
In your case, you could select your view (button, label, ...) and do one of the following :
ctrl+clic and drag on another view (not with the shift key) to make the pop-up appear :
do it with the menus at the bottom right :
Let me know if it helped.

Related

NSOutlineView disclosure triangle vertically off center

I'm working with an NSOutlineView on a macOS app and it provides disclosure triangles for items that can be expanded.
I'm also creating custom NSTableCellView items rather than using basic cell items. This allows me to create the cell how I want visually.
My issue is that when they're displayed, the disclosure triangle on the left is not centered vertically.
Notice how the disclosure triangles are not aligned properly. They're a bit lower than they should be. If you scroll away and come back, sometimes, they automatically align themselves correctly. Has anyone been able to fix this issue before?
For what it's worth, I'm using the following code as well for the cells.
self.outlineView.rowHeight = CGFloat(integerLiteral: 66)
self.outlineView.usesAutomaticRowHeights = true
It's hard to figure out what the problem is without seeing how you've set up your project, but I'm going to give it shot.
First, when usesAutomaticRowHeights is set to true, the outline view uses Auto Layout to position the cell views. Thus, you need to be utilizing constraints in your Storyboard or Nib file, or things will behave strangely (see: your picture). If I had to guess, the prototype cell view you set up in Interface Builder is having its autoresizingMask translated into Auto Layout constraints (which, generally, causes a boatload of problems).
What I would do is this:
Open up the Storyboard or Nib document containing the outline view.
Locate the prototype NSTableCellView instance that contains the street name text field in the Document Outline to the left of the canvas. (If you don't see the Document Outline, you can open it by clicking the item at Editor » Show Document Outline in the main menu).
Next, see if you have any constraints in place. If you do, remove them by selecting Editor » Resolve Auto Layout Issues » Clear Constraints under the menu item "section" that's titled All Views in ${YOUR_SCENE}.
Now, depending on what you're going for, there are different ways to go about setting up constraints, but here's what I would suggest. Assuming you want the street name to be centered vertically with the disclosure triangle, I would add a vertical constraint between the text field and its parent cell view like so:
With the text field selected in the Document Outline, click the Align icon in the lower right-hand corner of Interface Builder's main canvas area (see image).
In the popover that appears, check the checkbox next to Vertically in Container.
In the text field on the right side of the popover, enter a value of “0”.
Finally, click the “Add 1 Constraint” button.
You’ll probably see a red error (or yellow warning) sign show up, as the view has now opted into Auto Layout, but it only has a metric for its vertical position. So we now need to add some constraints to describe where the text field should be positioned on the x axis. Like before, we’ll define the constraints using the popover buttons on the lower right-hand side of the canvas:
Click the Add New Constraints button (the one to the right of the Align button).
On the diagram at the top of the popover, click the faint red lines on the left and right side of the white rectangle. This is telling Interface Builder we want to add leading and trailing constraints.
Now, enter the desired padding you want on each side of the text field. In the example image, I went with “4” points on both sides, but obviously, you can use whatever value(s) you think works best with your layout.
Finally, click the “Add 2 Constraints” button.
Any warning(s) that were present should now disappear, as we've added enough constraints to describe the position of the text field. In theory, you should now be able to build and run your project, and the text fields should be aligned with the disclosure triangles. With that said, there are plenty of other reasons a layout can get finicky, and considering usesAutomaticRowHeights is a new API in macOS High Sierra (and Steve Jobs is no longer there to beat it into Apple developers to make everything Just Work™), there could be issues that I'm unaware of.
Alternatively, you can set usesAutomaticRowHeights to false and have some object (e.g. a view controller, a NSObject subclass, etc.) conform to the NSOutlineViewDelegate protocol and implement the outlineView(_:heightOfRowByItem:) method to return any arbitrary height you want for different rows. The nice thing about sizing rows this way is that you can allow certain rows to be larger or smaller, depending on the role of the corresponding item. There are lots of tutorials on this, so I won't regurgitate a half-baked explanation here, but feel free to Google “Conforming to NSOutlineViewDelegate protocol” for more info.
Anyway, try the steps above, and see if they do anything for you, and if they don't, let me know. I can go as deep into the rabbit hole with you as you need, so just ask. Good luck!
For those like me who stumbled upon this issue many years later, here's the fix that worked for me, and requires a lot less work.
NSOutlineView has a function frameOfOutlineCell(atRow:) and the documentation states: You can override this method in a subclass to return a custom frame for the outline button cell
You can override the method in order to provide a frame that's actually in the vertical center of the row. And an important point that I learned from trial and error, is that you don't even need to provide that updated frame. Not sure if this is a bug or what, but for me, just calling super.frameOfOutlineCell(atRow: row) in the function override was enough to make the disclosure indicator appear in the correct location.
So my subclass of NSOutlineView is this:
class MyOutlineView: NSOutlineView {
override func frameOfOutlineCell(atRow row: Int) -> NSRect {
super.frameOfOutlineCell(atRow: row)
}
}
That's all. Hopefully that works for others as well!

How to Show the Code and design window in dreamwaver

I cant see the design of my code in dreamwaver. i want to switch the code to design. please help meenter image description here
Got to - View, Toolbar (right at the bottom), and select Document from the
fly out list (assuming it is unticked).

Swift UITextView size from NavBar to ToolBar?

So I'm working on an app but I'm pretty new to Xcode and swift itself, so thats what i have right now [textview color is just to show you its size]
http://i.imgur.com/55fC4Fb.png
But this is what I want:
http://i.imgur.com/VA1hZqO.png
i thought using top and bottom layout guides would help, but I'm totally lost. If anyone could help that'd be amazing! :)
I'm sorry, but i am new to this :/
One simple way to do this is to drag the text view between nav bar and tool bar, and then pin its top and bottom edges to nearest neighbors (in this case, nav bar and tool bar), like this:
http://i.imgur.com/7CADxPh.png
NOTE: make sure its edges are in between bars, not overlapping them. Also uncheck the Constrain to margins -box.
I got it to look like this very quickly:
http://i.imgur.com/AfksPdQ.png
There are many other ways to do this, and this is just one of them. Search for storyboards tutorials and you'll find many good tutorials how to use Interface Builder. :)

Disable Constraints in Xcode Storyboard

I'm trying to layout a very simple view. I've placed 4 custom buttons in the view in a grid like spacing. But when I run the app I get two of the buttons with different sizes. I've included the storyboard and simulator images here.
I would LOVE to disable constraints but cant find where to do it! I really don't want them. This is just for a simple prototype app and in the end I won't even have these buttons, I'll lay everything out in code.
I've tried dragging in 4 individual buttons AND tried just dragging in one and duplicating it to where I want. I just want them to stay where I put them! Any help would be appreciated.
-Mark
You turn it off in the File Inspector (first tab on left) -- there's a checkbox called "Use Autolayout" (it's checked by default).

Is it possible to move the tab bar to left and right direction in iPhone

Im developing a tabbar application.
There are almost 7 tabs in this app.
Usuall when we add more than 5 tabs a "more button"will come and rest of options will come under that "More option".
But i found a very interesting app in app store and they are moving the tabbar to left and right(just like we do in scroll view) like in the image below.
How can i implement this.
Can anyone help me with this please.
Thanks in advance.
As far as I can see, it's 2 custom UIButtons placed over the tabBar that may programmatically rearrange the tab options on their IBActions. What makes me say that is that the highlighted area of the last tab is just normal, and the arrows does not seem as well placed as what Apple could have done by standard.
You can use custom tabBar, like InfiniTabBar, nice and functional.
Project on GitHub:
https://github.com/iosdeveloper/InfiniTabBar