I create a new ViewController and renamed class. But still, the .h file where I want to store outlets and action doesn't appear.
In your xib or storyboard file change the Class in File's Owner to mach the one you had renamed.
See image:
When you add a new view controller and you think files *your controller name*.h and *your controller name*.m should automatically create. In my case, I start building a project(not in Visual Studio) in XCode. And after that, my files appear.
Related
i have used an imageview in the ios builder in visual studio whose refrence is automatically connected to my viewcontroller class and when i do set image to that imageview my app crashes with an error "This class is not key-value complient for the key image__"
As i am new to xamarin i am not aware if we need to do anything else inorder to make relation from storyboard to the class variable for access that particular outlet object.Please suggest me if you have any advice?
Open the storyboard in visual studio and then open properties pad. Select the image view and give Name in the identity option. Outlets from Xcode did not work in xamarin.
For example, your view controller name is TestView and you give the Name to image view as MyImage. Now there is one more file named TestView.designer.cs open that file and you will see that Outlets are generated in that file.
You might have accidentally removed the connection.
Is your imageView name: image__?
Given if the imageView is in ViewController.cs, look at the Solution Explorer, expand and find the ViewController.designer.cs and remove the imageView or image__(in your case) Outlet and whatever that's related to it and then re-link the Outlet again.
The problem was that the refrence was not working properly. I just removed the image outlet and viewController class and closed the project.Then i started creating that same class from very scratch and created the outlet from the storyboard. That was it. Everything started working COOL..!!!
I hope restarting the project helped me and it can help you too.Good Luck.
I'm writing an ASP.NET MVC 5 application, where folders are organized by feature (ViewModels, Controllers, and Views are grouped together). I was able to override all default folder paths and manage all routing successfully. However, every time I create a new controller, Visual Studio creates a new Views folder and a child folder with controller name, which is a little bit annoying but that's fine.
Now, when I create another controller, I'm getting this error, because Visual Studio created the Views folder again, which is hidden now (excluded from the project). To fix this, I have to include the Views folder in the project and delete it after I create the controller.
Does anybody know any way to prevent this?
Error
There was an error running the selected code generator: 'A file or
folder with the name 'Views' already exists on disk at this location.
Please choose another name.
If this file or folder does not appear in the Solution Explorer, then
it is not currently part of your project. To view files which exist on
disk, but are not in the project, select Show All Files from the
Project menu.
Instead of using visual studio's Add -> Controller which generates the undesired view folder, create your controller using Add -> Class. Name the class conventionally with a Controller suffix and subclass Controller like this MyController : Controller.
It happens that the IBOutlets in the new project are connecting to the storyboard of the original project? How to avoid? Or how to disconnect from the ViewController code?
Here you can see MainStoryboard_iphone is storyboard in original project, Main_iPhone_storyboard is storyboard in the new project.
Thanks.
I would suggest a simple hack if you don't have a lot of classes - create new files for every header file where you declare your IBOutlets and copy over the code - it might as well solve the problem.
I created a project in XCode 5 and imported it to XCode 6 beta, then later decided that I wanted to rewrite one of the ViewControllers in Swift. So I first deleted the controller file (both .h & .m) and added the same class named controller within a Swift file extension. Now when I try to hook up an outlet and action from the Storyboard by ctrl-dragging from the widget to the file, I can't create new connections.
Is this a bug or do I need to do something else to get it to work?
Seems to be bug in Xcode 6. You can resolve this by Changing the ViewController Custom class in the identity inspector to some another class press return and again change the class to original class you want then press return.
Using Xcode do I need to create a new file for each view when it is connected to a button? Or does it work fine with just keeping the app under one h and m file?
Create a new file for each view. This will give you a new .h and .m file. Using MVC or single app view.
iOS app development follow the model-view-control design pattern, and as such, you should always create a new control (.m and .h file) for each new view.