Ios Swift : Displaying Navigation Bar in custom Tabbar - uinavigationcontroller

I am trying to create a custom tab bar to place it on top of the screen using below code, programmatically. But the problem is, i am not able to get a navigation bar on top of the tabbar to go back to previous screen.
kindly help me.
override func viewDidLoad()
{
super.viewDidLoad()
let SrnBrdVar = UIStoryboard(name: "Main", bundle: nil)
let TabBarCtrVar = UITabBarController()
let TabBarVar = TabBarCtrVar.tabBar
let ObxSrnVar = SrnBrdVar.instantiateViewControllerWithIdentifier("ObxSrnUid")
let ObxNavSrnVar = UINavigationController(rootViewController: ObxSrnVar)
let IbxSrnVar = SrnBrdVar.instantiateViewControllerWithIdentifier("IbxSrnUid")
let IbxNavSrnVar = UINavigationController(rootViewController: IbxSrnVar)
UIApplication.sharedApplication().delegate!.window?!.rootViewController = TabBarCtrVar
ObxSrnVar.tabBarItem = UITabBarItem(
title: "Outbox",
image: UIImage(named: "NamItmDftImj"),
selectedImage: UIImage(named: "NamItmSltImj")?.imageWithRenderingMode(.AlwaysOriginal))
IbxSrnVar.tabBarItem = UITabBarItem(
title: "Inbox",
image: UIImage(named: "NamItmDftImj"),
selectedImage: UIImage(named: "NamItmSltImj")?.imageWithRenderingMode(.AlwaysOriginal))
TabBarCtrVar.viewControllers = [ObxSrnVar,IbxSrnVar]
TabBarVar.tintColor = UIColor.greenColor()
TabBarVar.frame = CGRectMake(
0,
UIApplication.sharedApplication().statusBarFrame.size.height + 64,
UIScreen.mainScreen().bounds.width,
50)
}

This worked for me. Hopefully it will be useful for you as well
let myStoryBoard = UIStoryboard(name: "Main", bundle: nil)
let myTabBarController = UITabBarController()
let leftController = myStoryBoard.instantiateViewControllerWithIdentifier("left")
let leftNavController = UINavigationController(rootViewController: leftController)
let rightController = myStoryBoard.instantiateViewControllerWithIdentifier("right")
let rightNavController = UINavigationController(rootViewController: rightController)
UIApplication.sharedApplication().delegate!.window?!.rootViewController = myTabBarController
myTabBarController.addChildViewController(leftNavController)
myTabBarController.addChildViewController(rightNavController)
let leftChild = myStoryBoard.instantiateViewControllerWithIdentifier("leftChild")
let rightChild = myStoryBoard.instantiateViewControllerWithIdentifier("rightChild")
leftNavController.addChildViewController(leftChild)
rightNavController.addChildViewController(rightChild)
print(myTabBarController.viewControllers?.count)
let but1 = myTabBarController.viewControllers?[0].tabBarItem
but1!.title = "Left Page"
let but2 = myTabBarController.viewControllers?[1].tabBarItem
but2!.title = "Right Page"
leftNavController.childViewControllers[0].navigationItem.title = "Left View"
rightNavController.childViewControllers[0].navigationItem.title = "Right View"

The below code worked for me to get navigation bar. But i am not able to add back button and make it work to move to previous screen.
Can anyone help me with this.
let SrnBrdVar = UIStoryboard(name: "Main", bundle: nil)
let TabBarCtrVar = UITabBarController()
let TabBarVar = TabBarCtrVar.tabBar
UIApplication.sharedApplication().delegate!.window?!.rootViewController = TabBarCtrVar
let Tab1SrnVar = SrnBrdVar.instantiateViewControllerWithIdentifier("Tab1SrnXid")
let Tab2SrnVar = SrnBrdVar.instantiateViewControllerWithIdentifier("Tab2SrnXid")
let Tab1NavCtrVar = UINavigationController(rootViewController: Tab1SrnVar)
let Tab2NavCtrVar = UINavigationController(rootViewController: Tab2SrnVar)
Tab1NavCtrVar.childViewControllers[0].navigationItem.title = "Nam1TabSrn"
Tab2NavCtrVar.childViewControllers[0].navigationItem.title = "Nam2TabSrn"
Tab1NavCtrVar.tabBarItem = UITabBarItem(
title: "Nam1Tab",
image: UIImage(named: "NamItmDftImj"),
selectedImage: UIImage(named: "NamItmSltImj")?.imageWithRenderingMode(.AlwaysOriginal))
Tab2NavCtrVar.tabBarItem = UITabBarItem(
title: "Nam2Tab",
image: UIImage(named: "NamItmDftImj"),
selectedImage: UIImage(named: "NamItmSltImj")?.imageWithRenderingMode(.AlwaysOriginal))
TabBarCtrVar.viewControllers = [Tab1NavCtrVar,Tab2NavCtrVar]
TabBarVar.tintColor = UIColor.greenColor()
TabBarVar.frame = CGRectMake(
0,
UIApplication.sharedApplication().statusBarFrame.size.height + 40,
UIScreen.mainScreen().bounds.width,
50)

Related

showing the drift chat widget for a particular page in wordpress

I have a word press website in which i am planning to show the drift chat window for a particular page only but the issue with the code is when i put the drift chat code in the header.php then it shows in the entire website at the footer. But my objective is to display that chat widget in a particular page not the entire site.
In header.php i placed this code.
<!-- Start of Async Drift Code -->
<script>
"use strict";
!function() {
var t = window.driftt = window.drift = window.driftt || [];
if (!t.init) {
if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
t.invoked = !0, t.methods = [ "identify", "config", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ],
t.factory = function(e) {
return function() {
var n = Array.prototype.slice.call(arguments);
return n.unshift(e), t.push(n), t;
};
}, t.methods.forEach(function(e) {
t[e] = t.factory(e);
}), t.load = function(t) {
var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
var i = document.getElementsByTagName("script")[0];
i.parentNode.insertBefore(o, i);
};
}
}();
drift.SNIPPET_VERSION = '0.3.1';
drift.load('963auir3rcg6');
</script>
<!-- End of Async Drift Code -->
How can i achieve it?
Any suggestions on it?
Replace this code in header.php
<?php
if(is_page(2)){
?>
<!-- Start of Async Drift Code -->
<script>
"use strict";
!function() {
var t = window.driftt = window.drift = window.driftt || [];
if (!t.init) {
if (t.invoked) return void (window.console && console.error && console.error("Drift snippet included twice."));
t.invoked = !0, t.methods = [ "identify", "config", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ],
t.factory = function(e) {
return function() {
var n = Array.prototype.slice.call(arguments);
return n.unshift(e), t.push(n), t;
};
}, t.methods.forEach(function(e) {
t[e] = t.factory(e);
}), t.load = function(t) {
var e = 3e5, n = Math.ceil(new Date() / e) * e, o = document.createElement("script");
o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + n + "/" + t + ".js";
var i = document.getElementsByTagName("script")[0];
i.parentNode.insertBefore(o, i);
};
}
}();
drift.SNIPPET_VERSION = '0.3.1';
drift.load('963auir3rcg6');
</script>
<!-- End of Async Drift Code -->
<?php } ?>

TinyMCE "EditMenuName" css property is not working after upgrading Episerver to version 11.5

After upgrading Episerver to version 11.5, the TinyMCE feature of being able to set custom names for menu items in a drop down is no longer working.
The special custom CSS attribute called EditMenuName is not working I guess. those menu items only showing particular CSS class names. not the names which are provided as "EditMenuName" attributes.
How do I get this feature working again?
There is no support for this. What you can do instead is to add these items to the style_formats, please see https://www.tinymce.com/docs/configure/content-formatting/#style_formats. More information on how you can customize the editor https://world.episerver.com/documentation/developer-guides/CMS/add-ons/customizing-the-tinymce-editor-v2/.
Here's an example configuration:
config
.Default()
.Schema(TinyMceSchema.Html5Strict)
.ContentCss("/gui/css/base.css")
.AddPlugin("link table paste code contextmenu")
.Toolbar(
"styleselect undo redo pastetext removeformat searchreplace code fullscreen",
"bold italic numlist bullist outdent indent table epi-link unlink image epi-image-editor epi-personalized-content")
.StyleFormats(
new { title = "Paragraph", format = "p" },
new { title = "Header 2", format = "h2" },
new { title = "Header 3", format = "h3" },
new { title = "Header 4", format = "h4" },
new
{
title = "Inline",
icon = "forecolor",
items = new[]
{
new { title = "Strikethrough", format = "strikethrough", icon = "strikethrough" },
new { title = "Superscript", format = "superscript", icon = "superscript" },
new { title = "Subscript", format = "subscript", icon = "subscript" },
new { title = "code", format = "code", icon = "code" }
}
},
new
{
title = "Blocks",
icon = "template",
items = new[]
{
new { title = "Blockquote", format = "blockquote" },
new { title = "Preformatted", format = "pre" },
}
},
new
{
title = "Images",
icon = "image",
items = new[]
{
new { title = "Left", selector = "img", classes = "left", icon = "alignleft" },
new { title = "Right", selector = "img", classes = "right", icon = "alignright" },
new { title = "Full-width", selector = "img", classes = "fullwidth", icon = "alignjustify" }
}
},
new
{
title = "Tables",
icon = "table",
items = new[]
{
new { title = "Left", selector = "table", classes = "left", icon = "alignleft" },
new { title = "Right", selector = "table", classes = "right", icon = "alignright" },
new { title = "Full-width", selector = "table", classes = "fullwidth", icon = "alignjustify" }
}
});

Swift link in a Annotation -> Webview

I try to find a way to add a link to a Annotation in Swift MapFramework, this link should forward the user to a WebView, as far i see i can't find any way to add a "touchable" link into a Annotations SubTitle
Here is my Code yet
class CustomPointAnnotation: MKPointAnnotation {
var imageName: String!
}
var info1 = CustomPointAnnotation()
info1.coordinate = CLLocationCoordinate2DMake(42, -84)
info1.title = "Info1"
info1.subtitle = "Subtitle"
info1.imageName = "1.png"
var info2 = CustomPointAnnotation()
info2.coordinate = CLLocationCoordinate2DMake(32, -95)
info2.title = "Info2"
info2.subtitle = "Subtitle"
info2.imageName = "2.png"
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
if !(annotation is CustomPointAnnotation) {
return nil
}
let reuseId = "test"
var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
if anView == nil {
anView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
anView.canShowCallout = true
}
else {
anView.annotation = annotation
}
//Set annotation-specific properties **AFTER**
//the view is dequeued or created...
let cpa = annotation as CustomPointAnnotation
anView.image = UIImage(named:cpa.imageName)
return anView
}
Is there maybe a way to use the UIGestureRecognizer for this?
I already tried it like
var longpress = UILongPressGestureRecognizer(target: self, action: "newInformation:")
longpress.minimumPressDuration = 2.0
info1.addGestureRecognizer(longpress)
But ending with "ViewController.CustomPointAnnotation does not have a member named addGestureRecognizer"
Here is a working solution
override func viewDidLoad() {
super.viewDidLoad()
//1
var lat1:CLLocationDegrees = 40.748708
var long1:CLLocationDegrees = -73.985643
var latDelta1:CLLocationDegrees = 0.01
var longDelta1:CLLocationDegrees = 0.01
var span1:MKCoordinateSpan = MKCoordinateSpanMake(latDelta1, longDelta1)
var location1:CLLocationCoordinate2D = CLLocationCoordinate2DMake(lat1, long1)
var region1:MKCoordinateRegion = MKCoordinateRegionMake(location1, span1)
Map.setRegion(region1, animated: true)
var info1 = CustomPointAnnotation()
info1.coordinate = location1
info1.title = "Test Title1!"
info1.subtitle = "Subtitle1"
info1.imageName = "1.png"
Map.addAnnotation(info1)
//2
var lat2:CLLocationDegrees = 41.748708
var long2:CLLocationDegrees = -72.985643
var latDelta2:CLLocationDegrees = 0.01
var longDelta2:CLLocationDegrees = 0.01
var span2:MKCoordinateSpan = MKCoordinateSpanMake(latDelta2, longDelta2)
var location2:CLLocationCoordinate2D = CLLocationCoordinate2DMake(lat2, long2)
var region2:MKCoordinateRegion = MKCoordinateRegionMake(location2, span2)
var info2 = CustomPointAnnotation()
info2.coordinate = location2
info2.title = "Test Title2!"
info2.subtitle = "Subtitle2"
info2.imageName = "2.png"
Map.addAnnotation(info2)
}
func mapView(mapView: MKMapView!, annotationView: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
if control == annotationView.rightCalloutAccessoryView {
println("Disclosure Pressed! \(self.title)")
}
}
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
if !(annotation is CustomPointAnnotation) {
return nil
}
let reuseId = "test"
var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
if anView == nil {
anView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
anView.canShowCallout = true
anView.rightCalloutAccessoryView = UIButton.buttonWithType(.InfoDark) as UIButton
}
else {
anView.annotation = annotation
}
//Set annotation-specific properties **AFTER**
//the view is dequeued or created...
let cpa = annotation as CustomPointAnnotation
anView.image = UIImage(named:cpa.imageName)
return anView
}

Create a custom legend in tabular format - ASP.NET Chart

I am quite new to ASP.NET Charting and have a question about adding custom component to a bar chart. I am trying to create a custom legend in a tabular format. What I mean is my legend style is table. And I am creating each LegendItem from database values and adding it to chart.Legends[0].CustomItems collection.
I get the data but I am getting all the LegendItems in one row. I want to display each LegendItem on new row. My current code look like this -
chart.Legends.Add(new Legend
{
LegendStyle = LegendStyle.Table,
BorderColor = Color.Black,
BorderWidth = 1,
BorderDashStyle = ChartDashStyle.Solid,
Alignment = StringAlignment.Center,
DockedToChartArea = areaCounter.ToString(),
Docking = Docking.Bottom,
Name = "CustomLegend",
IsTextAutoFit = true,
InterlacedRows = true,
TableStyle = LegendTableStyle.Auto,
IsDockedInsideChartArea = false
});
LegendItem newItem = new LegendItem();
newItem.Cells.Add(LegendCellType.Text, " - value1 - ", ContentAlignment.MiddleCenter);
newItem.Cells.Add(LegendCellType.Text, " - State Average = - ", ContentAlignment.MiddleCenter);
newItem.Cells[1].CellSpan = 2;
newItem.BorderColor = Color.Black;
newItem.Cells.Add(LegendCellType.Text, " - ", ContentAlignment.MiddleCenter);
newItem.Cells.Add(LegendCellType.Text, " - top - ", ContentAlignment.MiddleCenter);
chart.Legends[1].CustomItems.Add(newItem);
LegendItem newItem1 = new LegendItem();
newItem1.Cells.Add(LegendCellType.Text, "value1", ContentAlignment.MiddleCenter);
newItem1.Cells.Add(LegendCellType.Text, "State Average =", ContentAlignment.MiddleCenter);
newItem1.Cells[1].CellSpan = 2;
newItem1.BorderColor = Color.Black;
newItem1.Cells.Add(LegendCellType.Text, "", ContentAlignment.MiddleCenter);
newItem1.Cells.Add(LegendCellType.Text, "top", ContentAlignment.MiddleCenter);
chart.Legends[1].CustomItems.Add(newItem1);
newItem and newItem1 both appear on same row as legend. Can you please help me solve this issue ? I'd really appreciate your help.
Found out that once I add HeaderSeparator to my custom Legend object and handle the chat object's CustomizeLegend event it worked as I wanted. The custom items are displayed on separate rows. Here are the changes that I did.
chart.Legends.Add(new Legend
{
LegendStyle = LegendStyle.Table,
BorderColor = Color.Black,
BorderWidth = 1,
BorderDashStyle = ChartDashStyle.Solid,
Alignment = StringAlignment.Center,
DockedToChartArea = areaCounter.ToString(),
Docking = Docking.Bottom,
Name = "CustomLegend",
IsTextAutoFit = true,
InterlacedRows = true,
TableStyle = LegendTableStyle.Tall,
HeaderSeparator = LegendSeparatorStyle.Line,
HeaderSeparatorColor = Color.Gray,
IsDockedInsideChartArea = false
});
LegendItem newItem3 = new LegendItem();
var strVal = item.Value;
foreach (var val in strVal)
{
newItem3.Cells.Add(LegendCellType.Text, val, ContentAlignment.BottomCenter);
}
chart.Legends["CustomLegend"].CustomItems.Add(newItem3);
chart.CustomizeLegend += chart_CustomizeLegend;
void chart_CustomizeLegend(object sender, CustomizeLegendEventArgs e)
{
Chart chart = sender as Chart;
if (chart == null) return;
foreach (var item in e.LegendItems)
{
item.SeparatorType = LegendSeparatorStyle.Line;
item.SeparatorColor = Color.Black;
}
}

Adding text , image to asp.net chart control

I am using asp.net chart control to display chart on my website , below is the snippet of it:
The issue is i want to add the text and an arrow line on each point , so for instance on the point (60,october) I want to write text at this point: projection was highest and an arrow image.
Is it possible to acheive something like this, any suggestion or assistance will be highly appreciated, below is the code i have used to generate this chart:
double[] yValues = { 15, 60, 12, 13 };
string[] xValues = { "September", "October", "November", "December" };
chart.Width = 500;
chart.Height = 200;
chart.BorderSkin.SkinStyle = BorderSkinStyle.FrameThin1;
ChartArea ca = new ChartArea();
ca.Name = "Default";
ca.AxisX.LineColor = System.Drawing.ColorTranslator.FromHtml("#FEFEFE");
ca.AxisX.LineWidth = 3;
ca.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dash;
ca.AxisX.MajorGrid.Enabled = false;
ca.AxisX.MajorTickMark.LineWidth = 2;
ca.AxisX.LabelStyle.Format = "L";
ca.AxisY.LineColor = System.Drawing.ColorTranslator.FromHtml("#FEFEFE");
ca.AxisY.LineWidth = 3;
ca.AxisY.MajorGrid.Enabled = true;
ca.AxisY.MajorTickMark.LineWidth = 2;
ca.AxisY.Title = "yaxis";
chart.ChartAreas.Add(ca);
Legend legend = new Legend();
chart.Legends.Add(legend);
Series series = new Series("Series1");
series.IsValueShownAsLabel = false;
series.MarkerStyle = MarkerStyle.Circle;
series.BorderWidth = 5;
series.ChartType = SeriesChartType.Line;
series.ShadowOffset = 2;
series.XValueType = ChartValueType.String;
series.YValueType = ChartValueType.Double;
series.Font = new System.Drawing.Font("Trebuchet MS", 8);
series.BorderColor = System.Drawing.ColorTranslator.FromHtml("#33CCFF");
series.Color = System.Drawing.ColorTranslator.FromHtml("#33CCFF");
chart.Series.Add(series);
chart.Series["Series1"].Points.DataBindXY(xValues, yValues);
chart.DataManipulator.InsertEmptyPoints(1, System.Web.UI.DataVisualization.Charting.IntervalType.Days, "Series1");
You need to search for the largest data point and use property
datapoint.Label = "projection was highest";
Also easiest way to highlight the point is to use datapoint.MarkerStyle property. You can draw an arrow but I dont think its worth the hassle.

Resources