I am trying to get two progress bars with different labels in a horizontal field manager but only one is showing up. I can update it and change the progress but cannot see the second one.
// Internal Storage Label and Progress Bar
ProgressIndicatorView isView = new ProgressIndicatorView(0);
ProgressIndicatorController isController = new ProgressIndicatorController();
_isProgressBar = new ProgressIndicatorModel(0, 100, 0);
_isProgressBar.setController(isController);
isView.setModel(_isProgressBar);
isView.setController(isController);
isController.setModel(_isProgressBar);
isController.setView(isView);
isView.setLabel("Internal Storage");
isView.createProgressBar(Field.FIELD_HCENTER);
// SDCard Storage Label and Progress Bar
ProgressIndicatorView sdView = new ProgressIndicatorView(0);
ProgressIndicatorController sdController = new ProgressIndicatorController();
_sdProgressBar = new ProgressIndicatorModel(0, 100, 0);
_sdProgressBar.setController(sdController);
sdView.setModel(_sdProgressBar);
sdView.setController(sdController);
sdController.setModel(_sdProgressBar);
sdController.setView(sdView);
sdView.setLabel("SDCard Storage");
sdView.createProgressBar(Field.FIELD_HCENTER);
//Add everything to the view
//Add the manager to the screen.
add(horizontalFieldManager);
//Add the fields to the manager.
horizontalFieldManager.add(isView);
horizontalFieldManager.add(new SeparatorField());
horizontalFieldManager.add(sdView);
Related
I have a Xamarin.Forms app with FreshMvvm, and am trying to use secondary ToolbarItems. Here is a part of my PageModel code:
public override void Init(object initData)
{
CurrentPage.ToolbarItems.Add(new ToolbarItem() { Text = "About LATICRETE", Command = AboutCommand, Priority = 0, Order = ToolbarItemOrder.Secondary });
CurrentPage.ToolbarItems.Add(new ToolbarItem() { Text = "Call LATICRETE", Command = CallCommand, Priority = 0, Order = ToolbarItemOrder.Secondary });
CurrentPage.ToolbarItems.Add(new ToolbarItem() { Text = "Email Technical Support", Command = EmailTechSupportCommand, Priority = 0, Order = ToolbarItemOrder.Secondary });
CurrentPage.ToolbarItems.Add(new ToolbarItem() { Text = "Visit LATICRETE Website", Command = VisitWebsiteCommand, Priority = 0, Order = ToolbarItemOrder.Secondary });
For Android, after pressing the hamburger button, the menu looks like I expect:
But at iPhone, it is quite different:
As you can see, there is no hamburger button, and all the ToolbarItems are placed horizontally next to each other, and as they do not fit withing the width of the screen, they overlap. I realize that this is the normal behavior for iOS, and yet it is not acceptable for me. Is there any way to fix it?
On iOS, the Secondary items menu appears below the navigation bar as a horizontal list.
if you want to acheve the effect like in Android,you could create a custom PageRenderer.
here is a sample,you could refer to it iOSSecondaryToolbarMenubar
the effect in Android :
the effect in ios (you could change the icon in your renderer):
1) the first page has the toolbar items:
2) all pages have the toolbar items:
I am relatively new to iOS so go easy on me! In my app I need to have a button which contains an image a title. The image needs to go above the title. The image is defined dynamically from a base64 string.
My problem is I can’t work out how to display the title and the image in the button at the same time. I can display them individually but not together. I have tried following the approach in the below link but I have been unable to get it to work:
Display Button With Text & Image In Xamarin IOS
This is how the button needs to look:
In Xamarin iOS I am using the below code to set the image and lay out the controls in the button:
DeviceMenuItems m_menuItem = HHMenuContainer.Instance.GetMenuItems().DeviceMenuItems.SingleOrDefault(l => l.LineNo.ToString() == m_lineNo);
if (m_menuItem != null && m_menuItem.Base64Picture != null)
{
byte[] bytes = Convert.FromBase64String(m_menuItem.Base64Picture);
NSData data = NSData.FromArray(bytes);
UIImage uiimage = UIImage.LoadFromData(data);
//this line is not relevant to the problem
uiimage = ChangeImageBackground(uiimage);
if (uiimage != null)
{
//m_control is the UIButton
//commenting this out removes the image and shows the text
m_control.SetImage(uiimage, UIControlState.Normal);
float titleLabelHeight = (float)(m_control.TitleLabel.Frame.Size.Height + 10);
m_control.ImageEdgeInsets = new UIEdgeInsets(-(titleLabelHeight), 0, titleLabelHeight, 0 );
float imageHeight = (float)(m_control.ImageView.Frame.Size.Height * 0.5);
imageHeight -= titleLabelHeight;
m_control.TitleEdgeInsets = new UIEdgeInsets(imageHeight, 0, -(imageHeight), 0);
}
}
With the above code I get the following button (without the required text):
If I comment the ‘SetImage’ line out I get the following button:
Does anyone have any ideas why the above approach isn’t working?
From the shared link , it show left title and right image.If want up and down layout, you can try this:
button.TitleEdgeInsets = new UIEdgeInsets(0, -button.ImageView.Frame.Size.Width, -button.ImageView.Frame.Size.Height - 5,0);
button.ImageEdgeInsets = new UIEdgeInsets( -button.TitleLabel.Frame.Size.Height - 5, 0 , 0, -button.TitleLabel.Frame.Size.Width);
Note: If the button's frame is set and the width of the button is not enough to display the size of the image and text at the same time, the size of the titleLabel will get an error. So if you need to set the frame, it is recommended to set the width of the button to frame.size.width * 2, and then set the frame after the titleEdgeInsets and imageEdgeInsets are all set.
So I am trying to create a feature for a mobile app.
It needs to be able to display a pdf file in a view and allow a user to place a sizeable picture of his signature on desirable location.
I am working with xamarin.forms and to display a pdf file using this:
https://github.com/xamarin/recipes/tree/master/Recipes/xamarin-forms/Controls/display-pdf
Now I need to know what is the best approach for the second part.
A user places an image and all I need is to get coordinates of the location and its width.
So far I see two possible ways:
Create two views on top of each other, the first for pdf and second for the signature. Allow manipulation of the image in the second and get data from there. Not sure how to do it or if it is a good idea.
Make IOS use pdfjs in the same way as Android (having troubles with that) and on pdfjs side implement fabric.js and then get data from there.
Any suggestions or ideas for a better way to do it?
Thanks
You can add image and signature into webView.ScrollView , and make some adjustments on its ContentInset.
Change webView.ScrollView.ContentInset first.
Add additional view .
Make the webView scroll to the correct location(original anchor).
Complete code :
class MyDelegate: UIWebViewDelegate
{
public override void LoadingFinished(UIWebView webView)
{
webView.ScrollView.ContentInset = new UIEdgeInsets(200, 0, 0, 0);
UIView view = new UIView(frame: new CoreGraphics.CGRect(0, -200, webView.Frame.Width, 200));
UIImageView image = new UIImageView(frame: new CoreGraphics.CGRect(0, 0, webView.Frame.Width, 100));
UILabel label = new UILabel(frame: new CoreGraphics.CGRect(0, 100, webView.Frame.Width, 100));
view.Add(image);
view.Add(label);
webView.ScrollView.AddSubview(view);
webView.ScrollView.ContentOffset = new CoreGraphics.CGPoint(0, -200);
}
}
public class CustomWebViewRenderer : ViewRenderer<CustomWebView, UIWebView>
{
protected override void OnElementChanged (ElementChangedEventArgs<CustomWebView> e)
{
base.OnElementChanged (e);
if (Control == null) {
UIWebView web = new UIWebView();
web.Delegate = new MyDelegate();
SetNativeControl(web);
}
}
//xxxxx
}
I am using Xamarin Studio 6.0
I have created a TabBar and have added multi items to it, the items cover each others.
This is the code and screenshot:
var items = new UITabBarItem[10];
for (int i = 0; i < 10; i++)
{
var tabBarItem = new UITabBarItem("TAB ITEM"+i, null, i);
items[i] = tabBarItem;
}
TabLanguageBar.Items = items;
TabLanguageBar.ItemSpacing = 10;
TabLanguageBar.ItemSelected += (sender, e) =>
{
Console.WriteLine("tab bar button item slected");
};
That is the way a UITabBar works, you will need to either display a subset of them at one time or alter your UI design.
A tab bar displays all of its tabs onscreen at once, using the itemPositioning property to determine how to position items in the available space.
If you have more items than can fit in the available space, display only a subset of them and let the user select which tabs are displayed. The beginCustomizingItems: method displays an interface for selecting which tab bar items to display.
Ref: UITabBar
When I create a new UIDatePicker with its Mode set to a CountDownTimer, it renders poorly with a black background. Anyone have any insight?
Normal Picker looks like this:
CODE: Note the UIButton is a full screen button behind the picker to dismiss the view
intervalPicker = new UIDatePicker(new RectangleF(0, this.tvc.View.Bounds.Height - 135, this.tvc.View.Bounds.Width, 200));
intervalPicker.Mode = UIDatePickerMode.CountDownTimer;
intervalPicker.CountDownDuration = DeviceSession.CurrentBehavioralEvent.Duration*60;
intervalPicker.ValueChanged += new EventHandler(intervalPicker_EditingChanged);
UIButton b = UIButton.FromType(UIButtonType.Custom);
b.Opaque = false;
b.BackgroundColor = UIColor.Clear;
b.Frame = new RectangleF(0, 0, this.tvc.View.Bounds.Width, this.tvc.View.Bounds.Height);
b.TouchUpInside += (o, s) => {
intervalPicker.RemoveFromSuperview();
b.RemoveFromSuperview();
};
this.tvc.NavigationController.View.AddSubview(b);
this.tvc.NavigationController.View.AddSubview(intervalPicker);
The UIDatePicker in CountDownTimer mode displays this way when you set a frame height of less than 216. The other modes don't have this problem.
Your example is setting the height to 200.
Change the height to 216.