How to more easily "update all frames" in autolayout in Xcode7? - xcode

The "Update Frames" calls are often grayed-out in Xcode
the only way I know to have it update frames to match your constraints, is, tediously select your highest-level view and than (sometimes) you can fish in the menu bar for "Selected Views"->"Update Frames". Further, "All Views"->"Update Frames" would appear to often simply not work or work in a way I can't understand.
Surely there's just a keystroke or button which updates all frames straight away to match any newly-entered constraints (such as those made using control-drag).
Note .. for 2016 you can use this very handy button, which at least brings up the same sub-menu as you can find by searching in the menu bar menu.
However it would seem (see my comments w/ ZaBlanc below) that there is perhaps actually an Xcode bug, and you CAN NOT assign a keystroke to the "All Views" items. (The ones you usually use.)
Even worse .. in Xcode 8 ...
they seem to have removed the 'update frames' option ... WTH

It's easy. Go to Preferences -> Key Bindings. Type "Update Frames" on the top. You'll see two appear. You'll want the bottom one (it will be the one without a keyboard shortcut assigned.)
Assign it to ⌘= or anything else you like.
Life changed.
Just for anyone reading, with Xcode 8.3. The popup menu command no longer exists. The menu bar command Editor -> Update Frames does work. However there's a bug, the default key binding on that does not work. If you add a custom key combo, that custom key combo does work.

AFAIK, there is no keystroke for update all frames, but here's a key tip:
If you have a misplaced views, press the yellow arrow in the document outline (the views tree to the left of canvas), press yellow triangle on any view in the list, then select update frames and check Apply to all views in container - this will update all misplaced views in the selected view controller
Additionally, you probably already know:
You can add a new constraint with Add New Constraints button in canvas bottom right and select "Update frames" option.
You can select any view by mouse-click and holding Option+Shift keys - this will show you the list of all the views, that intersects with mouse pointer. After that you can select update frames menu item on a selected misplaced view.

The same as you, I thought that it's very annoying to fix the misplaced views manually by selecting them and choose that boring option from Xcode menu. After trying hard to shorten the time to fix the layout issues, I had to admit that there is no way to call the function "Update Frames" from command line. So I ended up doing this way:
Open Xcode warnings & error inspector window
Filter all layout warnings by using the keyword "frame for"
Click on warnings to quickly locate to the misplaced views then press Command + Option + =
That's the fastest way I know. Please try it out!
You could also find more details HERE

Related

Visual Studio 2013 - Replace All Button gone (not just off screen)

I am unable to perform multi-file text search and replace (in Visual Studio).
In the past, when I opened the "Replace in Files" dialog, there were 4 buttons in the lower right. One of the bottom two buttons allowed me to "Replace All".
The two lower buttons (including "Replace All") are no longer present.
I believe this occurred after I changed some Windows settings so that I could use menus without the Magnifier.
It is not just a matter of the buttons being off-screen because the window is too large (although it is too large - they would be off-screen, if they were present).
I can drag the window and see the bottom, even though the top is then off-screen (I use AltWindowDrag, allowing me to hold the ALT key, and drag by any part of the window, not just the title bar).
The two lower buttons are not present. I'm unable to resize the window - when I try, nothing happens, or the window repositions so that I can see the title bar, but can no longer see the bottom.
The two buttons that are still present (Find Next and Replace) don't have keyboard shortcuts, so I presume that Replace All doesn't either. Nor can I select either of those two buttons using Tab, so probably can't select an "invisible" "Replace All" button that way.
Any help appreciated.
You can use Find and Replace by pressing Ctrl+H and to Replace All just use Alt+A.

View is Clipping its Content error

I'm using Xcode 4.6. In a window I keep getting this "view is clipping its content" error and when I click on it, the XIB editor highlights a label. What is this error trying to tell me and how to I fix it?
First, clicking on the text "View is clipping..." will select the control that has the issue. it happens when you resize a text field too small for the inner text field cell to fit in. enlarging the control makes warning disappear. you can also select the inner cell and go to size inspector to see if there are options to make it smaller to match your desired overall size.
You have a carriage return / newline at the end of the text in your label. That empty line is part of the "content" which is larger than the "view". Get rid of your extra newline and you'll take care of this.
It's telling you that your constraints hasn't been set up correctly. You can resolve the by clicking on the view in question, then clicking on the small icon at the bottom and choose: "Reset to suggested constraints"
Or you could click on the little small orange (or red) arrow in your Document Outline (the list to the left of your view that shows all views), then click on Resolve Issue

How to use git mergetool's filemerge

The documentation is here: http://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html
A handy guide is here: http://ryanflorence.com/git-for-beginners/
However, neither of them explain how to use mergetool's filemerge.
The guide I read says "I hit enter and FileMerge pops up and I deal with the conflicts:" but it doesn't mention how to "deal with the conflicts".
When I run:
git mergetool
:and then hit return as prompted, and the filemerge window opens showing all the merge conflicts, it only responds to the commands cmd+D and cmd+shift+D (which allow cycling through the conflicts). However, there doesn't seem to be a mention of how to, for each conflict, choose left/right/neither. The combo-box dropdown does not seem to do anything.
Have already looked at docs, guide, file system menu, and systematically pressed keys on the keyboard looking for a response =)
I haven't found any official documentation for it, but here's the understanding I got from trial and error:
There's a split view with your two options on the left and right. You can't edit either of those. There's also a bottom view which you can edit. You might need to pull up on the little circle in the middle of the bottom of the screen to expand that section.
For each conflict, click on the area in middle of the left/right split view and choose from the drop down in the lower right either "Choose Left" if the left is what you want or "Choose Right" if that is what you want. If neither option is good, click "Choose Neither" and edit it in the bottom section.
There's an arrow in the middle column that will show whether you've chosen left or right by pointing at it. If you've chosen neither, the arrow will disappear. All three views scroll together using the scroll bar on the far right screen.
When you're done, click File > Save Merge from the menubar.

Find method references in Xcode

Is there a way in Xcode to find all the places where a method or property has been been called?
In Eclipse, for example, you can right-click a method and select Find references. Is there anything similar in Xcode?
Select the method you're interested in, or position the text cursor within it.
Open the "Related Files" menu via the icon at the top-left of the Editor. (It's the button immediately to the left of the back button).
Go to the "Callers" submenu for a list of all methods that call the selected method, and click any of them to jump to that file and method.
In pictures...
A couple of notes:
You can do this for properties too.
Note that when you select a calling method from the Callers menu to jump to where your method was called, Xcode highlights only the first call. Each calling method will only show up in the 'Callers' list once, even if it contains many calls to your method. So if you're trying to make some change at every place in your application where a method is called, be careful not to miss some in places where a calling method contains two calls to the method you're interested in.
Yes, open the Assistant editor and instead of Counterparts select Callers.
Select function, press cmd-shift-A, "Callers"
As of XCode 4.5 you can click on "Show find options" within the search field of the Search Navigator. There you can specify "Symbol References"
Place the insertion point in a method invocation or declaration and choose Find > Find Selected Symbol In Project. For multipart selectors this will only highlight the first part but searching does seem to work relatively reliably. You can also use Find Call Hierarchy which highlights the entire line instead.
The corresponding contextual menu item (Find Selected Symbol in Workspace) also works, but it's a bit trickier to make work properly. Make sure no text gets selected otherwise it'll search for the selected word rather than the entire selector. To do so, you can click with the left mouse button prior to clicking with the right mouse button (or Control-clicking) in the same location. There's no such issue with the contextual Find Call Hierarchy.
With xcode 4 you can now right click on references and select "jump to definition."

Xcode find caller functions

In Xcode, how can I find all caller functions of a specific function?
Xcode 4.5 (in beta) has this functionality. when you highlight say... a function, you can check the "caller" and "callee"
edit i believe it's located at the top left of the file panel for that file... so double click on the function to highlight it, and you click on on the file panel options (the one that has the "open recent, open unsaved...etc" drop down
EDIT #2
here's a picture to clarify (since i dont know what this menu button is called):
ALSO - XCode 4.5 is no longer beta, i believe, and is actually out in public
EDIT #3
also note that this caller thing does NOT search for being called under the performSelector method, as in, the particular caller that has this performSelector won't show up if you had done something like:
[self performSelector:#selector(checkIfShouldStopMovement) withObject:nil afterDelay:0.25];
In Xcode, the quickest method is this:
Select method in code (double click or mark using your mouse cursor)
Press Ctrl+1
Select "Callers" from the pop-up menu.
This is the shortcut for going View -> Editor -> Show Related Items in Xcode's menu.
use ⌘+Ctrl+Shift+H key combination on Xcode 7 onwards.
This can also be accessed via the assistant editor, as shown in the screenshot below. Whichever method you have the insertion point in in the main editor on the left will have its callers displayed in the assistant editor. I've found this to be the best way of looking through each caller in succession, since once you have "Callers" selected, you can then select the next caller via the next pop-up menu to the right in the jump bar.
In Xcode-7 you have the functionality of getting call-heirerchy. Right-click on the function and click "Find Call Hierarchy":
image reference:
Xcode 10 upwards seems to have made it easier. Just Command Click on the function and you should see it in the drop down.
Press ⌘+Ctrl+Shift+H shortcut when a method of interests is selected (with a mouse or cursor). (as per #uiroshan 's answer)
But you can also specify any another shortcut in XCode -> Preferences -> Key Bindings
Use Find in Project as Text or as Symbol.
AFAIK, there's no equivalent to e.g. Call Hierarchy known from Eclipse or NetBeans.
Strangely the refactoring tool can detect all method calls but not the search.
So I simply use it to rename my method to a unique name (eg. reset to resetPlayer) and then use the new name in a regular textual search.
1.) Menu > Edit > Refactor... > Rename to unique name
2.) search for the new name
The functionality is available in XCode 4.4.1, see this: http://smilingfinney.blogspot.de/2012/09/method-callers-in-xcode-44.html

Resources