the method that handles the button action never inserted when the button is dragged - objective-c

I am trying to drag a button in the .m file as shown in the image below, but after releasing the mouse button the method that handles the button when clicked was never implemented.
please let me why that method gets never inserted in the .m file??
image:

Choose your ViewController in IB by clicking on the yellow circle with a square inside. Select the third tab on Xcode's right pane. Choose ViewController as your class for this IB item from the combobox. After that, the binding should work.

The storyboard viewcontroller must be a subclassed from the class you are trying to drag into (by default its UIviewController) If it's not then it won't work...
From your storyboard click on viewController and then in the inspector panel on your right change it to the right class and you should be all good.

Related

How do I add border to an #IBAction Button that is linked from storyboard in Swift 2.1?

How to set button border if the button is linked to storyboard and is of type #IBAction?
The button's type is not IBAction, the IBAction is the connection between the storyboard and the function
if you want to change the button in the code, connect it from the storyboard as an outlet
(hold ctrl and drag the button from storyboard to your viewController)
(and u can also change it from the storyboard)

popping ViewController into NavigationController

I have a navigation controller, root - tabViewController, and i have one more ViewController, it isn't in Navigation controller, there is in ViewController - button.
How can i do on Clicking this button new viewController pops in current Navigation controller?
After a long series of comments ... How you are using this app couldn't be more different than the original question.
You need to replace the PKRevealController front viewController when the button is clicked something like this:
[self.revealController setFrontViewController: newViewController];
I have try to understend your question but i dont know if its that what you need:
Place a button in your firstViewController
move your mouse on that button and hold "ctrl" key
drag to the next view controller and choose push option
That's it!

How to bind click action of NSButton in view based NSTableView

I have an NSTableView that is set to be 'view based', and within each NSTableCellView there is an NSButton and an NSTextField.
The text field is being populated correctly from an array controller. The buttons are appearing correctly but I'm having trouble working out how to hook up the click action.
I thought this would be possible by control-dragging from the NSButton in IB to a simple method like this one in my controller (in this case an NSDocument subclass):
- (IBAction)testAction:(NSButton *)sender {
NSLog(#"Test action");
}
It connects fine but never gets fired. Any ideas why this is or how to fix it?
I don't understand why this works, but I had the same problem and was able to get it working by assigning the table delegate and datasource to the file owner within IB, which is also the class of my click handlers. Only then did it seem to actually bind the click handlers for the buttons in my cell view. Previously I was setting the delegate and datasource in code after the view was loaded.
You have to subclass NSTableCellView class. put your onClick Action method in subclass files.
Let me know if i am not clear..

Show NSWindow on right click in NSTableView

I'd like to display an NSWindow when right clicking an item in an NSTableView, similarly to how the available outlets are shown in Interface Builder when you right click an object:
Unfortunately you can only use an NSMenu subclass as the menu property.
I also didn't find a delegate method of NSTableView that notifies about right clicks.
I was able to subclass NSTableView and implement rightMouseDown: and rightMouseUp: to be notified about those events, but if I set the menu property of the row cells to nil, they are not highlighted when right clicked, even though I call the super implementation):
- (void)rightMouseDown:(NSEvent *)theEvent {
[super rightMouseDown:theEvent];
NSPoint eventLocation = [theEvent locationInWindow];
eventLocation = [self convertPoint:eventLocation fromView:nil];
NSInteger rowIndex = [self rowAtPoint:eventLocation];
NSLog(#"Right clicked at row index %d", rowIndex);
}
I would like to have the highlight effect in the image below but display a window instead of the context menu:
First for the right click: explicitly select the row on right click (e.g. via this message). Then create your own NSWindow descendant, set an own NSView class as contentView and in the view you can draw the black background, rounded borders and what not. Show this window in your right click handler.
You can use an NSPopover, which works quite nicely. A popover creates a window for you, even if it is somewhat hidden. You'll get it from your controls if you send them the window message, and can register to listen for events, for instance.
The whole popover can be created in IB, and just have to implement the showRelativeToRect:ofView:preferredEdge: method in code.
To catch the right click event, you can use rightMouseDown:, which is originally defined in NSResponder, but is overridden in NSView to simply catch the event and show menu and it doesn't pass the event upwards in the responder chain (or the inheritance chain, for that matter). Hence, you simply implement that method to call showRelativeToRect:ofView:preferredEdge:.
You will typically need to have the contents in an NSViewController and its own accompanying nib file.
The NSPopover's contentViewController property can be set in IB, too.
All in all, not much code needed.
This tutorial is useful.

uibutton hide and dropdown text

I have a signup button that switches screens for a signup form. I'd like for it to hide the button and drop down text boxes beneath when the button is tapped (instead of switching screens). Is this possible? Currently I have in my .h file...
#property (nonatomic, strong) IBOutlet UIButton *emailSignUp;
- (IBAction)hideButton:(id)sender;
and in the .m file my method is as follows
- (IBAction)hideButton:(id)sender {
[self.emailSignUp setHidden:YES];
}
However it seems to be crashing whenever I try to test. Any advice? I thank you guys in advance. I know there is a long way to go, but I feel this is my first step.
It sounds like you haven't connected the button you created in the Interface Builder portion of Xcode to the emailSignUp IBOutlet. You can do this by going to the Interface Builder, selecting File's Owner and then the Connection Navigator (in the right side panel, designated by the arrow icon in the tab bar). Then, drag from the Outlet to the button.