Cannot create a model segue by dragging in Xcode - xcode

I am new for Xcode , I am trying to build my first easy project by following this video:
https://www.youtube.com/watch?v=v9bsZvHuQYI
However , between 2:23 to 2:25 , the way he try to create a segue from home to another view controller is not working , I try to drag by holding ctrl and left mouse to another view controller there is nothing response (usually it will appear a blue window to tell you can link with it) , is that cause by the new version of Xcode?
I'm appreciate for any advice, thanks!

It may have to do with the version of your editor, but you can always create a segue that's not associated with a button click or a table row click by control dragging from the View Controller icon on the controller. I had trouble making a screenshot so please excuse my drawn in mouse.

Related

How do I make the view controller navigator thing go away?

I am working in Xcode 13.1 and I have a small version of my view controller hovering above the view controller I am working on. It appears to be a way to auto-focus my actual view controller window on a specific portion of the view controller, but in actuality it is just in my way. Is there a way to toggle off this feature? I can't figure out what it's called, but here is a picture.
enter image description here
This is called mini map. You can disable the mini map by clicking the storyboard options.

Where did tabbed controller views go in storyboard?

Forgive but I haven't coded in about a year or two, so I haven't been following the latest update in Xcode.
Anyways, I decided to go back and brush up on some skills and I noticed right off the bat that a lot has changed.
I created a new project using the tabbed view controller set up, usually it shows in storyboard immediately upon creating the project. Now there is nothing there. Where did it go and how do I bring it back?
I attached a screenshot so you can see the simulator running the tabbed apps but not showing in storyboard.
enter image description here
You opened the LaunchScreen.storyboard. This layout appears on the screen for a few moments while the app is launching.
https://developer.apple.com/documentation/uikit/app_and_environment/responding_to_the_launch_of_your_app
https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/launch-screen
The storyboard that you are looking for is Main.storyboard
Notice, that there is no Main.storyboard if you start with SwiftUI
There are no specialized app templates any more. But there is still a tab view controller object in the storyboard editor's library, so just drag it into the canvas and use it. It gives you same two-child tab view controller as before.

In Xcode, how do I create an outlet for a button that is inside a container?

I'm a total newbie with xcode and swift, trying to wrap my head around ios programming.
I'm designing a storyboard for my app. The storyboard uses containers to keep track of the controls. In one of the containers resides a button. I want to create an outlet for it to add some code when it is clicked.
If the button would be on the base viewport of the storyboard, I would control-drag a blue line from the button to the source window with my UIViewController subclass file, and it would assist me in generating the code. But for some reason when the button is in a container, this just doesn't work.
When following the documentation, it says to open the assistant editor when the button is selected and it should open the relevant file. So it open an objective-c file, but when I try to control-drag into it, it informs me that I do not have write permissions. Also I feel like I should be doing it in a subclass instead.
I have searched online a lot and tried everything I can think about, but nothing has worked so far. How does this work? Can I do it programmatically or so perhaps? I hope someone can straighten out this question mark...
A container view is intended to represent an area that will host a view from a different view controller that becomes a child of the view controller that owns the container. Usually, you would create a second view controller, link your container view to it using an "embed" segue, and then put your buttons and such in the second controller's view. The code behind those would then go into the second controller.
If your purpose is simply to have superviews to control layout within a single view controller, use a UIView rather than a container and the problem goes away. That's what the Editor->Embed In->View menu item is for.

Xcode osx scroll view

I am going round in circles trying to get a custom view to scroll correctly.
To simplify this.
I create a new OSX cocoa application.
Go to the xib file, select the window. drag a custom view, then drag a few buttons into it.
Run the program, you have a button in the screen.
Now go back the custom view, select editor -> embed in -> Scroll view
Everything looks fine, and suggests you will have two buttons with scroll bars in the custom view.
Run the program, the custom view shows with scroll bars, but the button do not show.
What am I doing wrong?
Following your instructions I have created and changed the project. No problem.
Run in IB your "app", CMD R. The user interface itself can be checked in this way.
If problem remains
Check the layer position->Click on the custom View
Is it possible to Layout->Send to back? If yes, then your button-scrollview is not embedded.
Unembed the button, view and repeat the process, by checking in IB if now the interface shows appears correctly.

Mac OSX NSStatusItem with Custom NSMenu/MenuItems AND Drag And Drop functionality

I am trying to create a Mac Application that has an NSStatusItem icon in the Status Bar. The status bar icon should support file drag and drop and must also show a menu when clicked.
The problem is that I have managed to achieve both functionalities separately and am having a hard time merging them together.
I was able to create a Status Bar Application using this link :
http://cocoatutorial.grapewave.com/2010/01/creating-a-status-bar-application/
And then I was able to achieve drag and drop functionality on the status bar icon using the following link
Drag and Drop with NSStatusItem
The problem that I am facing is as follows, in order to get drag and drop, I have to create another view and then assign that view to the NSStatusItem as shown below :
NSStatusItem *statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
ViewWithDragFunctionality* viewWithDrag = [[ViewWithDragFunctionality alloc] initWithFrame:NSMakeRect(0, 0, 24, 24)];
[statusItem.view addSubview:viewWithDrag];
Since this is just a view, it does not, obviously, behave as the NSStatusItem's default view and does not support mouse interactions or anything else.
I managed to find a way around that by adding the following function to ViewWithDragFunctionality.m
- (void)mouseDown:(NSEvent *)theEvent {
NSLog(#"Status Bar Icon Clicked");
}
The function is called whenever the status bar icon is clicked and file drag and drop is also being detected.
But now I am stuck with figuring out how to get the menu to display when clicking the status bar icon.
Any help will be much appreciated. I am working on a solution for this and will post it here if I find something first :)
Regards
Shumais
After many days of hit and trial, looking for appropriate tutorials and banging my head against the wall to no avail, I finally stumbled across an imgur application code base generously hosted on github for the public.
The code was hosted at gihthub by a user called ZBUC.
The code that helped me out is at the following repository location on github : https://github.com/zbuc/imgurBar
This is exactly what was needed, after studying how he/they did things in there and combining what I learned/found with the links mentioned in the question, I was able to create a Custom status menu item for my application, was able to get a proper menu to drop down as is the case with a default status menu item and was also able to add drag and drop functionality to my applications status menu item.
So now I have a Custom Status Menu for my application which works like a normal status menu and also supports drag and drop functionality.
I hope that the links in the question, along with the repository link posted above, are of help to everyone who needs what I did.
Thank You
Shumais

Resources