Are there any tutorials on UIPopoverController or creating UIPopovers without using interface builder?
I want to learn what is happening first before I use IB. All of the tutorials I have seen have been with interface builder.
I learned very fast with the sample code "Popover" at the Xcode library. It shows with very simple coding how set up a popover and present it.
Related
I want to write a MacOS Cocoa Desktop App with XCode 10 and Swift 4.2.
It should have a searchfield with a suggestions view opening as you keep typing like Google Search or Spotlight with autocompletion.
However I'm completely new to Cocoa programming.
I have already tried to add an NSSearchField and a dynamically added NSPopOver object with subclass of NSTableView which contains all the suggestions. But I am not happy with the suggestions view because of the anchor/arrow that appears with it. It seems like it breaks the UI guidelines.
Thus I have tried to implement my own custom subclass of NSView containing the suggestions. It works fine but I struggle with simple things like making it hide/disappear as soon as any other area is clicked in the app.
Does anyone know a good example as best practice for this task or have some sample code?
I often make use of views in interface builder that live outside of the viewcontroller hierarchy (see screen grab below for simple example).
Before upgrading to Xcode5 I could get this view to appear on the storyboard by writing an IBAction outlet and dragging a connection from the code to the view in the storyboard.
If you paused over the button for a moment it would flash and then open up as a view on the storyboard that is then a lot easier to work with.
Since upgrading this function no longer seems available. Has anyone found out how to get these views to appear on the storyboard?
Edit:
Using the temporary viewcontroller as described in this answer seems one approach, although fiddly since you need to move the UIView stack between viewcontrollers each time you want to edit the layout. Using a separate XIB is starting to seem like the sanest approach.
https://stackoverflow.com/a/13713385/1060154
Finally, we get this back in Xcode 7.
Hallelu!
I am extremely new at Xcode. I am building an app that has a collection view in it. It looks great in the storyboard view, but nothing shows up when I run the simulator. I have images and labels in the cells. I have created a subclass for the cells and made my connections for the images and labels into the .h file. For right now I am just making a stub prototype (cells don't link to anything). If anyone can give me an answer or just suggest something to try than that would be great.
You're making a dynamic prototype - to actually show data, you need to read up on datasources and delegates.
If I were you, I would start with trying to make a simple UITableView app first. Google UITableView tutorial to get started.
After you're familiar with the above concepts, then would I suggest to go through a collection view tutorial - it's a relatively simple set of concepts when you get it, but you have to get it first :)
I have a question regarding setting up a simple single view application. From what I can see there are two methods...
METHOD_001
Start Xcode and create a "Window Based Application"
Start setting up your interface in the MainWindow.xib
METHOD_002
Start Xcode and create a "Window Based Application"
In Xcode add a UIViewController subclass with its own XIB.
In Xcode add an IBOutlet to the delegate to point to UIViewController
In Interface Builder add an instance of UIViewController and link it at the delegate
In Interface Builder select the "NIB Name" the UIViewController will use.
To my mind METHOD_002 would seem to be the way to go for anything other than the most simple of tests. Also its following the MVC methodology, so I would suggest that METHOD_001 is just a starting point and you should always be heading towards METHOD_002?
gary
Between the two alternatives, the second one looks better for the simple reason that it has more loose coupling, probably making it easier to switch things around later. I'm not sure you could say that it's more MVC, because at this point you don't yet have any model objects, and even with the first method you have both a view controller and a view.
I usually don't use interface builder but from what I have gather it seems that interface builder if mostly for building self contained window. Is it possible to create a view with IB and then import this NIB file and use it as a subview?
To add what Peter wrote: Yes you can, and it's also a fairly common method. For example, since 10.5 there's a class called NSViewController which does just that, and the interface builder has a template for that, too.
The steps are:
Create a view in the nib file.
Connect it to an outlet of the File's Owner.
Load a nib, supplying the file's owner. If you use NSViewController, it's done by -initWithNibName:bundle:. In this case, the view is set at [self view].
There's no step 4.
Slightly off topic, but I think it's worth spending some time for you to learn a bit of Objective-C and Cocoa program using it, before directly delving into the world of Cocoa bridges to other languages, be it RubyCocoa, PyObjC, or clozure-CL. That's because almost all of the Cocoa documentation, blog posts etc. is written for Objective-C. Objective-C is not a difficult language to learn, especially if you know OO and C already.
Yes. One of the templates is for a stand-alone view. If you have a nib already, you can drag any view from the Library panel into it.