I've started working on an Alloy & Titanium project, and i need to create a new window with a new view. I've already created the files, and created the controller and view in my index.js file.
function onListClick(e) {
var win = Alloy.createController('controlPage').getView();
win.open();
}
This is the code that is supposed to open the new View, but...
Uncaught TypeError: Object View has no method "open"
I've immediately checked the online reference, and there actually is no module "open" inside the Ti.UI.View object.
What am i supposed to do? controlPage.xml (and the relative .js and .tss file) do exist.
Well,
is controlPage.xml:
<Alloy>
<Window>
</Window>
</Alloy>
If it is, then you can win.open() since window objects have an open() method
If however, you actually have a view as your title, the references to Ti.UI.View, etc indicates, then you would need to add your view to a parent container.
Related
I've got a Blazor app that is referencing a custom web component (<omnibar-navigation>).
This component has an items property that should be a json object that looks something like this:
[{'title':'Home','icon':'places-home-1','url':'/','metadata':null,'items':null}, ...]
I'm wondering how to bind a C# complex object to that items property.
var options = new List<Nav> { new Nav { Title = "Home", Icon = "places-home-1", Url = "/" } };
Then the binding would be something like this (doesn't work):
<omnibar-navigation items="#options">...</omnibar-navigation>
A code repo for this problem is here: https://github.com/dahlsailrunner/blazor-oidc.
The page with the exact problem is here: https://github.com/dahlsailrunner/blazor-oidc/blob/master/Sample.Blazor/Pages/Stencil.razor
The component is imported on the Pages/_Host.cshtml file.
Great question. I noticed also some issues with binding a web component directly via Blazor data binding, especially with the connectedCallback of the web component which is a kwown issue.
But the great thing is:
If something in Blazor doesn't work, you can always use JavaScript Interop to make it work!
I've created here a blog post for you that shows how to integrate a web component via JS Interop that has such a property/attribute that takes a complex object: https://www.thomasclaudiushuber.com/2020/02/14/initializing-web-components-in-blazor-via-js-interop/
It also shows how to wrap the web component with a native Blazor component, so that you can bind it just with C#. :-)
Here is a git repo with all the code: https://github.com/thomasclaudiushuber/Blazor-Using-Custom-Web-Component
Happy coding,
Thomas
You're going to build a component with a Parameter property that receives an IEnumerable of your Nav type. You just need to deserialize your JSON and bind it to that collection.
Check this gist for how you can deserialize the JSON and bind to the collection in the index.razor file
https://gist.github.com/csharpfritz/c4dcfcc731826822e0764728bbd9d88c
I have moved most of the core functionality of my non-document based macOS app to a custom, embedded framework.
The app code has a standard main storyboard with an initial window, and the window has a "window content" relationship/segue into a storyboard reference pointing to a storyboard inside the embedded framework. Therein lies a custom NSViewController subclass and a custom NSView subclass.
I want to group all the input event handling code inside the framework, which means implementing mouseDown(with:) on the custom NSView subclass, and --lo and behold-- it gets called when I click inside the app window. So far, so good.
Next, I implemented keyDown(with:) to similarly handle keyboard input. However, at runtime, it does not get called and instead, I hear the annoying beep (NSBeep).
I tried implementing keyDown(with:) on the view controller instead, but it's all the same.
Finally, I tried implementing the key handler on my NSWindowController subclass instead, and that does work.
So I could get around this by forwarding the event like so:
class WindowController: NSWindowController {
override func keyDown(with event: NSEvent) {
contentViewController?.view.keyDown(with: event)
}
}
, but it is very inelegant. I would prefer to not pollute the app code with input logic.
This doesn't seem to have anything to do with embedding frameworks, however. I put together a minimal project from the 'Cocoa App' template and confirmed that indeed keyDown(with:) only gets called if implemented on the window controller code, but not on the view or view controller side.
How can I get keyDown(with:) to be called on the view or view controller (not the window or window controller) in a storyboard-based app? (so I can move it from the main app to my embedded framework).
Edit: The question has been marked as duplicate. I tried the solutions pointed in answers to the other question (namely, override acceptsFirstResponder to return true). This solves the problem in my minimal demo project, but when I tried it on my full app, it still does not work (I did see that question and did try to override acceptsFirstResponder in my app before posting this question).
I will now try to modify my minimal poeject to see if I can reporduce the issue in the main app.
Edit 2: I have refactored the minimal project to:
Send the view controller to a separate storyboard,
Send the view controller's storyboard and represented classes (custom view, custom view controller) to a separate, embedded framework.
Now the basic setup mirrors that of my app in all that seems to matter, but still can not reproduce the issue in the minimal project. I will investiate further...
Edit 3: I haven't been able to reproduce the issue on the minimal project.
On my app's custom view, I implemented:
public override var acceptsFirstResponder: Bool {
return true
}
public override func performKeyEquivalent(with event: NSEvent) -> Bool {
let retVal = super.performKeyEquivalent(with: event)
return retVal
}
On startup, acceptsFirstResponder is called twice.
When hitting any key, performKeyEquivalent(with:) is called twice, too. Inspectig the intermediate variable retVal above reveals that the super class's implementation always returns false. After returning from this method, NSBeep() is called and keyDown(with:) isn't.
If instead of super.performKeyEquivalent(with:) I force-return true, I can avert the call to NSBeep() (but keyDown(with:) is still not called...)
Edit 4 (Final):
Out of desperation, I cleared the "Custom Class" field of the window controller's Identity Inspector in my app's main storyboard (to the default NSWindowController).
Suddenly, my custom view's keyDown(with:) starts getting called.
I reinstated the custom class to confirm.
It still works.
I clean the build folder and try again.
It still works.
Now I can no longer reproduce the issue even on my main app. I really don't know what to say...
I am a .Net Developer and just started my first iOS project using swift. I want to navigate from one view controller to another using code. Like we do in WP 8.1 with the help of following code:
Frame.Navigate(Typeof("Page_2"));
Another way that you can do it depending on how you are calling or executing the code.
self.performSegueWithIdentifier("YourSegueIdentifier", sender: self)
Give your destination view controller an identifier (in storyboard). Then, put this into the view controller you're navigating from...
let controller = self.sender.storyboard?.instantiateViewControllerWithIdentifier("resultController") as! ResultController
controller.myViewModel= myViewModel!
self.sender.navigationController?.pushViewController(controller, animated: true)
Here is the flow of my app so far.
View controller (HOME) with rect button (modal) linking to > Table view controller with an embedded navigation controller linked to> Multiple View controllers with an image on each.
This work perfectly s but......
I want to have a "back" button on my Table view controller to take me back to my (HOME) View controller.
I am new to this and have tried to find relevant info and tried loads of options but noting seems to work and although i can see a button in the simulator (and have Modal linked it to my (HOME) view ) the simulator crashes every time and this error message appears.....
*2013-01-05 17:19:40.080 MASTER DETAIL POLAR TEST[10975:f803] -[HomeController setCharacterNumber:]: unrecognized selector sent to instance 0x6894620
2013-01-05 17:19:40.084 MASTER DETAIL POLAR TEST[10975:f803] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[HomeController setCharacterNumber:]: unrecognized selector sent to instance 0x6894620'**
Please Help.....
may it would be the best your HOME viewController is embedded in the navigationController an become RootViewController. By clicking the rect-button the tableViewController will appear.
Use the navigationControllers method – pushViewController:animated: or create a new segue an select "push".
If you don't like this way you have to add a navigationBarButtonItem to the navigationBar. Link this button item to an action which send the message dismissViewControllerAnimated:completion: to the tableViewController. This should work.
I am a beginner to Obj-C and Xcode 4 and I am currently going through the "Your First Mac Application" on the Mac Dev website. I have managed to get through the main part but I'm struggling on the "Refactor the Application Delegate" section.
I have created a new class (to use as a controller), added an object set to this new class, made the connections from the class to the slider, mute button and textfield, and I have connected the new class object to the app delegate interface file.
Unfortunately an instance of the track class is never created, and therefore the program doesn't work, as the awakeFromNib function never gets called. I have tried placing it in both the app delegate file and the new controller class.
Where am I going wrong???
You have to either create an instance of your new class in IB, or you need to create it programmatically in your AppDelegate object (usually in init or awakeFromNib). You need to have a pointer to that object in your AppDelegate. If you create the new object in IB, you connect it to the Track* pointer in IB. If you do it in code, it's something like:
in .h file:
TrackClass *track;
in .m file:
track = [[Track alloc] init];
Which did you do?
I had the same issue while trying out the tutorial and found out the problem was with my implementation of awakeFromNib
Wrong Code:
- (void)awakeFromNib:(NSNotification *)aNotification
Right Code
- (void)awakeFromNib
There should be no argument passing the implementation of awakeFromNib.