Having Trouble Making a Button in Xamarin.Mac/XCode-Storyboard - xcode

Let me start off by saying I am new to XCode, but already very experienced in C#. I am having trouble getting the outlet for this button, and every time I try to Control drag it under ViewControl it only lets me do action! I have been googling for about 3 hours and trying to find tutorials, but everyone else's code looks different by default :(

You are trying to drag into the ViewController.m file, you need to be in the header file (ViewController.h) to create an Outlet.
Change the file being edited:
Now Ctrl-Drag into the .h file:

Related

Search Bar doesn't register input

I created a MapView and a SearchBar in a .xib file. I loaded the xib file into a ViewController was testing it in the simulator. The MapView works as it should, but the SearchBar doesn't register any input. Whatever key I press on my keyboard, the SearchBar just shows my cursor and the placeholder text. I used the SearchBar in another project to see if it works there and it does. I can type whatever I want to in there.
I don't know why it doesn't work in my loaded .xib file. Doesn't it work in .xib? I also cleaned and rebuild everything and made sure that user interaction is enabled. I enabled it in code and Xcode.
Here are my attributes for the SearchBar from Xcode. I think everything is right but maybe it helps.
Any ideas?? Thanks in advance!
Edit:
I found out that I'm not only unable to make an input, but also can't add (or see) a scope bar to the SearchBar. Again, I could add it in another project but not in this current one. No matter if the scope bar is enabled or disabled, I can't see it when I click on the SearchBar.
It turns out that I had a problem in my SceneDelegate. I still don't understand why and how this error occurred but I somehow missed this in my SceneDelegate:
this.Window = new UIWindow(scene as UIWindowScene);
If you are experiencing the same issue or want to know why, here's another question I've found with the working solution

Swift 3 Xcode 8: CoreData self.managedObjectContext.hasChanges returns false

I've been following this guide.
And I ported it to my code, I have the folders being made in my library folder, the file contained is a size of "0 Bytes". Inside my tableView I am able to click and add/delete items. So it does have a connection to CoreData. However when I wish to save the results of the tableview, it steps right over the line. I put a breakpoint in and cannot see the variable (nor what I'm supposed to be looking for).
I've been trying for two days to tackle this now. I've read up on google, was using these as a reference, and still no luck. My code and bindings matches up with the sample code provided.
Reference
any ideas? things to check that I haven't already done? It does seem like a link "disappeared" but everything is all on the same viewcontroller which is what is confusing me.
Figured it out. Right Click under delegate and the saveAction will be visible. Link it to your button. Voila! nOOb mistake. Learning here!

Unable to find UIView in UIStoryboard

I'm using Xamarin.iOS in Windows. Everything is working fine except:
Sometime ago, I'd create a UIScrollView named MyScrollView inside an UIView at MyViewController.
Right now, I can use it normally programatically like:
MyScrollView.AddSubview(myButton);
The problem is:
I can't find the MyScrollView at the Storyboard Designer. I want to change some properties at the designer.
Question 1:
Is there a way to delete it and recreate since I can't find it at designer?
Question 2:
Is there a way to use a search at the .storyboard file?
EDIT:
Even if i right click over my UIView at the UIViewController, the Context menu doesn't shows the UIScrollView.
For some reason, It was created at the storyboard back-end, however it was just not showing at the Designer.
By adding the same component with the same name: MyControllerView it didn't duplicate, and assumed the original position.
Note: Special thanks to #Yuri S. It didn't solved by this answer, but i didn't know that i'm able to edit the storyboard via XML. So lesson learnt.

Moving from one viewcontroller to another viewcontroller in Mac OS X using Xamarin.Mac

I am a complete newbie in Mac development. I want to achieve the following functionality :-
I have a view with a two textfields and a login button.When the user clicks on login button another view should open.
Now my main view is in MainWindow.xib file..
I added another view using
Add-> New File-> Xamarin.Mac-> Cocoa View with controller, which generated the following files:-
1.) NewView.cs
2.) NewView.xib
3.) NewViewController.cs
After searching quite a lot on net i did not get the exact way to achieve this functionality. I referred this thread
Easy Switching of "View Controllers" in Mac Apps (similar to iOS)
but could not get the much out of it. Can someone tell me how to simply navigate from one view controller to another using Xamarin.Mac and where what code is to be written??
Any links,code snippet or sample code will be of great help!!
Thanks a ton in advance!
Here is the answer :-
If you want to switch from one view to another below code snippet shows how to add and remove views:-
Write the below two lines in your Action of login button.
Previous view will be removed and new view i.e SecondView will be added.
this.View.Superview.AddSubview(new SecondViewController().View);
this.View.RemoveFromSuperview();
Cheers!!

How can i make a .XIB from .h and .m files?

I'm working on an existing project which I basically need to create a .XIB
so I can then put in UIToolbar and UIButtons ect.
On the App already it has a Tab bar but has been inputted through code and not the Interface Builder.
I would appreciate any guidance on my problem.
Kind Regards.
There is no automatic code that does this for you. You'll need to look in the code, find all UIView instances that need to go into the nib and manually create it. Then you'll have to be sure to set the frame of each of them to the same positioning as what is defined in the code. Finally, you'll have to be sure to remove all of that from the code (once it is fully migrated to the nib). Finally, you'll have to be sure that the components are referenced only after the nib has fully loaded (which might not have been the case in the current code).
Why not keep the components in the code (and just use nibs for new views)?

Resources