Xcode/ Custom Button/ Alignment - xcode

I am having a weird problem with xcode, I created a button with an image in it, and trying to put center the image in the button.
It is weird that if I click center horizontal in xcode, it always one step close to the left side. If I set it align with the right side, it isnt going to the right end. Anyone have any cue what is wrong with my xcode...
thanks for helping me out, please see the screenshot for your information.
1

In size inspector, check a Content insets and Image insets right and left if are set to zero

Related

How to fix "Scrollable Content Size Ambiguity" in Xcode 11 (iOS 12, iOS 13) using Auto Layout

When using Auto Layout, I am unable to set up a simple UIScrollView in my view controller in Xcode 11 beta. I know that I must constrain the scroll view to the edges, and then set the scroll view width and height equal to the width and height of the entire view that contains the scroll view. However, I am not getting the option to set equal widths and heights when I attempt to do so.
When I do the right-click-drag from the scroll view to the entire main view, I get the following options:
Leading Space to Safe Area
Top Space to Safe Area
Trailing Space to Safe Area
Bottom Space to Safe Area
Center Horizontally in Safe Area
Center Vertically in Safe Area
In other videos, there is an "Equal Widths" and "Equal Heights" option that I don't seem to have.
Am I doing something wrong, or did Apple change the way scroll views work in Xcode 11?
Disabling the content layout guides in the size inspector (ruler icon) in properties
I was having the same issue, and by disabling the option it was gone.
I stacked with that problem as well.
Found a good guide that helped me:
https://useyourloaf.com/blog/scroll-view-layouts-with-interface-builder/
Basically what you need is 9 constraints (assuming you want to scroll only vertically):
1-4: ScrollView to Superview (top, bottom, leading, trailing). Make sure to connect it to parent view and not to safe area.
5-8: Content view to Content Layout guide (top, bottom, leading, trailing).
Content view Width equals width to Frame Layout Guide.
I also encountered this problem (Version 11.0 beta 3 (11M362v)). I solved this problem by first setting the layout in xcode10 and then running it in xcode11. I haven't found any official instructions yet, proving that this is a problem with xcode11, but for now, I guess this is a problem with xcode11 bate.
After spending a long time on this scrolling issue in Xcode-11. The conclusion on this issue is you have to choose the scrolling option while adding a new constraint.
You can refer to the following screenshot to resolve your issue.
These mentioned solutions worked for me.
Disabling the content layout guides in properties worked for me.
Well, I was facing this issue but I have found a solution.
Problem is the Safe Area.
Embed Scroll view in a UIview.
give Top, Bottom, Right and Left 0.
now give constraints of scroll view with this view.
Add Equal height and width of content view to this View.
parent view is automatically giving Safe Area. All you have to do is just embed your scroll view in a UIview and then give equal height and equal width of the content view to this view.
#Vadim's answer worked with a little adjustment.
Nothing else worked and I didn't want to disable 'Content layout guide'. Since apple enabled it, why disable it. So there must be something I'm missing or it's a bug.
Vadim's answer is:
I stacked with that problem as well. Found a good guide that helped me:
https://useyourloaf.com/blog/scroll-view-layouts-with-interface-builder/
Basically what you need is 9 constraints (assuming you want to scroll only vertically):
1-4: ScrollView to Superview (top, bottom, leading, trailing). Make sure to connect it to parent view and not to safe area.
5-8: Content view to Content Layout guide (top, bottom, leading, trailing)
9: Content view Width equals width to Frame Layout Guide.
All good, but it didn't work,
But then I realize that the above 6 and 8 (trailing and bottom constraints to 'Content Layout guide') constraints are a little weird. They had positive constant values instead of zero. Like the below image. (constant equals to width and height of the scroll view). I changed them to zero and now it all works.
For me, initially the Content Layout Guides is in disabled state by default in ScrollView. So I just enabled and disabled the Content Layout Guides then the error disappeared automatically.
Xcode 11+, Swift 5.
I solved my issue, I prepared video and code

Set Interface Builder Tag

I wanted to know how would I set a tag in the IB of Xcode. I currently have not done anything to try and fix this.
It's pretty easy. Just go to the storyboard, click on the view you want to tag and look here:
Make sure you're on that 4th tab at the very top, the Attributes Inspector
If you don't see a side bar, make sure the right drawer is opened by tapping on that right-tab-icon on the VERY top right corner (the one that's blue in my pic, it'll be gray if its closed)

A control in NSTableCellView is being moved to right automatically after resizing or scrolling

I'm trying to implement a counter view that shows items count in NSTableCellView.
The weird thing is it gets moved to right automatically after resizing window or scrolling the NSOutlineView which has the NSTableCellView.
Here is some screenshots of it. You will be able to see the counter view which shows "42" being moved to right after resize the window.
Following is the init state of the counter view.
Following is the state after resize window.
Following is difference between init position and the position after resize window.
Cell Autoresize Property
Count Button Autoresize Property
I'm guessing this is related to scrollview but I was not able to find more clues about this issue. BTW, official Mail App on Mac works as same with this but the difference is the counter of the Mail app is being changed right after launch so it does not being moved after resize window.
Anybody knows about this? Any thoughts would be appreciated.
Here is a link that allows you to download the sample project that apple provides and you can reproduce what I'm facing.
Sidebar Demo App that providing by Apple.
You just need to change Deployment target before you run it from Project -> Targets -> Deployment Info section.
If I interpret the autoresizing screenshots correctly, the '42' control is behaving as specified. You've pinned the right side of the '42' counter to right side of the cell. And that is where it stays, glued to the right side of the cell.
The cell is pinned to the left side of the tableview and that is where it stays, glued to the left side of the tableview. You have not pinned the right side of the cell to anything and so when you resize, the right side goes where it pleases, only maintaining the specified width of the cell. If you want to glue the right side of the cell to the width of the tableView or column (not sure which it is), pin it. Do specify a minimum width for the cell. If you don't specify a maximum width, or fixed width, the cell will stretch and shrink with resizing. If you fix the width, only the right view or column will stretch.

xcode constraints not working

I'm trying to figure out how the new Xcode constraints work, but it doesn't make sense. I'm trying to set the top, left, and bottom constraints at 0 from view borders for a table view so when I resize the window, my table would resize to fill from top to bottom. But it stays the same size when I resize the window. When I launch the app in full screen, the table is getting set to top to bottom, but if I make the window smaller, I think it cuts half of it off. Seems like it doesn't refresh when I click the resize window button. Anyone have any ideas? Thx
Try this tutorial: http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1 . It might be helpful.

Auto Layout view resizing frustrations when designing in Interface Builder

Problem: UIView size is "locked" when designing with Auto Layout in IB
I've uploaded a 20 second video that illustrates my problem, but let me describe it. You may recognize the project: it's right out of Apple's WWDC 2012 "Introduction to Auto Layout." I've got a simple iPhone view in Interface Builder where I've already got a button and label along the bottom. The next step is to add a UIView. Here's where things get ugly.
When I drag the UIView out of the palette in Interface Builder and onto the iPhone window, as soon as I let it go it seems to become locked in to its starting size. I place it in the upper left corner, and I'd like to drag it horizontally to the right side of the window, and vertically to where it will be up against (minus the padding) the button and label along the bottom. But, when I try to resize it, I cannot. It's stuck on its original size!
The video illustrating my problem is here:
http://www.youtube.com/watch?v=jsW4UwnCEkw
You can see me grab the right edge of the view and try to pull it along to the right side of the window, but it won't expand. You can then see me move the entire view to the right side (it retains its size) and then try the opposite: grabbing the left side and trying to expand it so that it sizes up against the left side of the window. In both cases, the view is simply locked to its original size.
What gives! Auto Layout in Interface Builder is just the most frustrating thing. How do I resize a view by dragging? Thanks!
(Note: Xcode 4.6.3.)
In IB, in the series of buttons in the lower right hand corner, click on the rightmost button:
When you do, you'll see a "When resizing Views Apply Constraints To..." pop-up menu:
Make sure that "Siblings and Ancestors" is not checked.

Resources