How to set font family to Navigation Controller Title in swift? - uiviewcontroller

I have one View Controller named "Home". I embed it in Navigation Controller.
self.navBar.topItem?.title = "Home"
I would like to change "Tharlon" font to my UIViewController title bar.
self.navBar.topItem?.title = NSLocalizedString("Home", comment: "")
self.navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "Tharlon", size: 17)!]
Both these codes are in ViewDidLoad() function. When I run the app, Translated text shows well at the first time. Then, I open other menus and goes back to Home. At that second time, translated text does not show well and it does not looks in Unicode font.
That works well at the first time !
This is not well after I view other pages and goes back to Home.
I also tried to put these above code in ViewWillAppear . But it still not works.
Please, can anyone help me?

Related

Xamarin Forms - WinPhone - Formatted text

My app needs to run on Android, iOS and WinPhone 8.1. It needs to have a page with a long text that include a lot of format:
bold
bullet list
link (http, mail, phone)
Because it has to run on all 3 platforms, I tried to create an HTML string in order to send it to a WebView like this :
MyWebView.Source = new HtmlWebViewSource {Html = stringHtml };
So I can use <b> for bolds, <ul> for bullet lists, <a> for links.
Because I need also a custom font and specific size, in my html string there is a new style with all these the informations.
It works.... but with 2 problems on Windows Phone:
all the bullet list font size are really smaller than the rest of text
all the pages show a blank webview, but if I reload it (a lot of times) or wait 3/4 seconds then it shows the content
Any idea about these problems?
And if there's another solution different from WebView... it's welcome!
Xamarin.Forms includes a FormattedText property in the Label (this guide should help you to understand it: Xamarin.Forms FormattedText). But there are some things you want to do that can't be done with it, and these are:
FormattedText doesn't have links, but if I'm not mistaken, if you use links in a WebView, they will only work within that WebView, so the link will be open in the same space as your text.
FormattedText doesn't have a bullet list. You can go around this problem adding the ASCII bullet character (in windows: Hold ALT and press the number 7) and some spaces to indent the paragraph.
The rest of what you want (bold, italic, color changes, etc.) FormattedText has.
Hope it helps! :)

Going to a specific section from exterior link

I am trying to create an anchor in order to be able to build such an URL :
www.mysite.com/#myAnchor
which should automatically link to the div wanted, even from an exterior website.
However, when I am trying to implement it, here is the adresse to which I am redirected : www.mysite.com/#/myAnchor
So far, I tested different things such as :
<a name="myAnchor" />
<a name="#myAnchor"></a>
<a name="myAnchor"></a>
<span class="anchor " id="myAnchor"></span>
But nothing seems to work.
However when I am on the page I can change the url to go there but from "outside" this just redirects to the top of the page.
Thanks for your help.
That most likely happens because the first anchor is done by the browser, and when the page loads for the first time I assume the content is not all loaded yet (using views?).
If that is the case, then you need to call the service $anchorScroll that angular provides somewhere in your code after the view has been loaded (on a ng-init maybe?). Something like
<a name="myAnchor" ng-init="loadScrollToAnchor()"></a>
And then in your controller, after injecting the service $anchorScroll.
var scrolled = true;
$scope.loadScrollToAnchor = function () {
if ( !scrolled ) {
$anchorScroll();
scrolled = true;
}
};
Update: The scrolled variable is there to make sure that the code is only executed once (at page load), and thus this code should reside in an application-wise controller and not a controller specific to a route or view. However, there are still some shortcomings to this approach that might need to be countered, like if the view that the user loads the page first has no ng-init calling the function, and then he moves to another view that does: the code will execute, and the user viewport will possibly be changed against the user's intents.
To solve it, I actually only had to add this line of code without anything else :
This is doing the trick.

Navigate inside UserControl

I'm working on a application where I load a XAML page inside a usercontrol,
depending on which menu item was clicked.
After figuring out how to load in XAML page in a XAML page (using usercontrol), I'm running into the next problem: Navigation.
I added a picture to illustrate what I'm working on.
When you launch the app, you see the left state (state open), where the menu is presented and a little bit of the content on the right.
If you click the red button, the page scrolls to a "full screen" of the right state (state closed). This is still the same page, the MainPage.xaml, but with a new page loaded in the usercontrol. Let's say the loaded page is news, where you can select an article by clicking.
This all works great.
The problem is, when I try to use the navigationservice to see a detail of the news, the app fails. (it does work when I set the news page as start page, but it won't work inside the usercontrol).
I tried fixing this by the following code:
NewsDetail detailpage = new NewsDetail();
this.Content = detailpage;
Actually, this works.. but then I can no longer pass a querystring to load a certain article on the page.
Any ideas on how to fix this problem?
You can use a static variable in App.xaml.cs when querystrings become useless.
just declare a static variable of type say string in app.xaml.cs
public static string MyString;
just assign it a value before navigation
App.MyString="Hello";
And get this value where ever you want to get it.
string ss=App.MyString;

Welcome screen before entering UINavigationController (Storyboard)

I've tried to add a welcome screen to my storyboard. my main storyboard consists of a UINavigationContoller.
I have set the first page which is empty to initial view controller then had a button set to push to my UINavigation controller. Why doesn't this work?
Surely there must be a simple way of having a page before the UINavigationController.
EDIT:
I should add I need more than one image in this empty view controller and I need to animate them so a simple splash screen image wont work.
I don't know if this will help, as it is shown very short but works: in your target, you can set an icon but also a load-up screen or loading screen, if you make a n image, and place it there, it will show up while loading the storyboard. I'm not sure if this will help, but I'm not that good at objective c. Good luck!
-JonanJi

create a page which contain a flash can be add text dynamiclly

I have to create a web page which can be set to full screen(I mean the real full screen,not like press the F11),in the full screen there should be some words displaying.
Take the http://stackoverflow.com for example:
Normally,it show its contents(the questions),but someday,maybe a VIP come to visit the page,so we want to replace the whole page with a welcome screen.
Of course we can replace the https://stackoverflow.com/index.html (suppose it is the index page) with the welcome text(welcome xxx to our site...) in the server side.
However this is not convenient,and the text can not be full screened.
So I thought the flash,I can add a controller button at the page,when required,I click this button,and set the welcome words,then a flash will start to play with the sepcified words in a full screen model. It would be better if the flash can show the text with a Animation.
I have never did the flash development,so I want to know if this is possible?
BTW,can all the clients change to flash with juse one click?
I mean I click the controller button,then all the client who is visit this page should see the contents replaced by the flash at the same time.
I am not sure if you guys know what I am meaning. If not,I can update more details.
I am really Anxious, Thanks. :)
Since you're starting from scratch with Flash, I made a quick example of what I think you want to do. http://clearmpls.com/temp/fullscreen/ - the source files that I made this example with can be grabbed from here: http://clearmpls.com/temp/xml-loading-fullscreen-thing.zip
I used the Flash IDE to create this. You can grab a 60-day trial from Adobe's site here: https://www.adobe.com/cfusion/tdrc/index.cfm?product=flash
This example shows examples of these functions:
- it loads an XML file with text data
- displays that data in a textfield on the stage
- gives you a button where you can toggle back and forth between fullscreen and regular
- resizes the stage and textfield based on what you have written in your XML file