TYPO3 how to set specific view - typo3

How to set specific view in my extension?
$this->view->assign('example', $example); - it means that view path must fit with controller and action names. I need to set specific views with another path and name! Is it possible?

You can use $this->view->setTemplatePathAndFilename('path/to/your/template.html'); to set a custom view.

Related

Is there a way to create a header for multiple View Controllers in xcode?

I need some help on creating a "Header" for multiple View Controllers without copy/pasting every time the line of code into the new view controller I create.
Something like creating a header in PHP and including it into the pages you want.
In the header I want to add custom text/data.
I tried creating a View on a single View Controller and then implementing that view on multiple storyboards, but it doesn't work and doubt that's the way of doing it.
I tried looking for something similar to what I needed but couldn't find it.
I am new to swift/xcode.
Thank you
Create subclass of UIView with nib.
When adding instance of this view to view controller, also create
constraints(or create them with interface builder).
Add setup
method that takes String argument and sets the label outlet.
If you meant header that will push all the view controller content down, that's hard to implement and I don't advice it.
I need some help on creating a "Header" for multiple View Controllers without copy/pasting every time the line of code into the new view controller I create.
There are at least three ways to do this:
Common view: Create a common view that you just add to each scene where you want the header displayed. RealNmae gives pretty good instructions for that, as does the possible duplicate that matt linked in a comment, so I won't try to describe that approach again.
Inheritance: Put the code to create the header in a view controller class that's otherwise empty. You might call it HeaderViewController or something like that. Then make all the view controller classes that need to display the header subclasses of that HeaderViewController class.
Containment: Create a container view controller that displays the header. Container view controllers can draw part of your UI, and then let a contained "child" view controller handle the rest. UINavigationController and UITabBarController are examples of container view controllers -- they draw a bar at the top or bottom of the screen that provides some functionality, and everything else gets drawn by the contained view controller(s).

How to change class dynamically for view controller using interface builder

there are different conditions for same design file. i can't use if-else in same class file to differentiate them. because manage all conditions are difficult. is there any way to change class at dynamic time.
Yes, we can set class using Xib. But from my research i didn't find any way to change storyboard class dynamically. I found other way to reuse the view like using container view. following link shows how can we reuse storyboard view.
Diego Lavalle describe it on medium.
and you can read about container view at here.
I think you can use a master view controller and can load different view controllers as child based on some condition.
For example in Master View controller you can use UIsegmentedControl and based on the option the user chooses, you can show different view controllers.
Refer the following for implementing the same.
https://medium.com/#Dougly/creating-a-custom-view-controller-navigation-interface-programmatically-swift-3-1-8c9e582cdb30

Perform a segue when HTML link is touched

I have some HTML content in my app using UIWebView. I'd like to have a link in the HTML content that trigger my app to perform a segue or load another view controller.
For example, if I have some HTML content that includes the text "Check out our current specials", I want to use an tag to enable "specials" to load the Specials view controller from the storyboard.
Is there any way to achieve this?
I don't have code to show you but I believe I can show you the right direction because I have had to do this before. Here is a way to do it.
In the hyperlink create a link that has a unique scheme name and path. For example use MyScheme://GoToThisScreen/Identifier.
Set the UIWebView delegate to your file owner and ensure the file owner implement UIWebViewDelegate.
Override the webView:shouldStartLoadWithRequest:navigationType: and examine the URLRequest that comes from the web view. If it is not your scheme (MyScheme) then you can let it pass through.
If it is your scheme you can use it to determine you next step. For example segue to another screen.
Use the UIStoryBoard method instantiateViewControllerWithIdentifier: where the identifier is assigned to the scene you wish to instantiate (last part of URI). Remember you must get the correct storyboard to use this.
Push the View Controller you received in step 5 into the navigation controller.
Hope this helps.

Best Way To Create an "Add" View Controller

I have a table view that contains a list of Project objects. When an item is selected it brings up a detail view. Pretty standard. What is the best way to implement "add" functionality (popup a modal view controller to input new values and save the item)?
Currently I have view controllers for my root view, detail view, and add view. Essentially the detail view and add view are exactly the same except for a save & cancel button in the add view. Is it possible to reuse the detail view in the add view?
Finally, what is the best way to display the list of project properties in a grouped table view separated into sections?
Thank you for your responses.
Most likely, you are already passing your detail view controller a managed object that it is supposed to display when in detail view mode. When the user decides to add a new project, just create a blank object, pass it to the detail controller and display it. (You might want to insert this blank object into another "empty" managed object context in case the user cancels the add process to avoid having to clean up your main managed object context in that case.)
The detail view controller would also need a flag that tells it whether it is in edit or add mode so it can adjust its controls (and possibly delegate messages it sends to its owner) accordingly. You would set the flag to the appropriate value before you display the controller.
It sounds like you're looking for a UINavigationController. The UINavigationController lets you push new view controllers on top of existing ones. It gives you a navigation bar at the top that will allow the user to go back to the root controller. I think it's the kind of controller Apple uses it in the default email application, to give you an example.
Concerning organization: you design your root view controller and a detail/add view controller. In your app delegate, you attach a UINavigationController to the window and you set its root controller to the main controller you want to display. That root controller can then push the add/detail controller onto the stack (and when it does so, it can tell the add/detail controller which types of button to display.)
I can't answer your grouped properties question, but it sounds like a separate question anyway.

How to embed one nib into another?

There are many view that share a common part in my current project so I just visualize a way to encapsulate the common part into a nib file that could be shared by many controllers by embedding it to their corresponding nib file. Although I know how to do it programmatically, I still believe there should be a way to achieve this simply in Interface Builder. Are there anyone who has achieved this and would you like to point the way out?
You can add in your NIB file a view called "Content", for example. In your code, the only thing you need to do is add your new UIViewController's view inside the "Content"'s view. This way, you can achieve a view that holds common data, while the only thing you do is to change the view inside the "Content"'s view.