locked
how to display image in xamarin.IOS native? RRS feed

All replies

  • User369979 posted

    If you have placed your ic_success.png image at right position, you have constructed a right UIImageView control. Then you need to show this control on the root view of current view controller using View.Add(imageView), why do you comment that? But first of all, you should have a correct position image. According to this documentation, we should put our images in the resources folder as possible. So that we can use the image's name directly without the folder's name in the path. Also the default build action for images will be BundleResource – don’t override this value unless you have a specific reason.

    Thursday, July 12, 2018 4:46 AM
  • User370365 posted

    Set image using View.Add(imageView) that time set image on the full screen but my requirement is set to image on perfect one section.

    Thursday, July 12, 2018 4:53 AM
  • User369979 posted

    @akslmn Do you mean you want to put this image in your DialogSection? Which library are you using? The DialogTextAlert and DialogSection are not system controls on native. Can you share the code of them?

    Thursday, July 12, 2018 9:03 AM
  • User370365 posted

    Yes, I put my image in DialogSection. I used (System.Collections.IEnumerable).

    Thursday, July 12, 2018 9:23 AM
  • User369979 posted

    @akslmn I mean where does DialogSection control come from? Can you post code about it or some related link about it?

    Thursday, July 12, 2018 9:51 AM
  • User370365 posted

    null

    Thursday, July 12, 2018 9:52 AM
  • User370365 posted

    namespace demo.Mobile {

    public class DialogSection : System.Collections.IEnumerable
    {
        public DialogSection(string header, string footer)
        {
            _elements = new List<DialogItem>();
            Header = header;
            Footer = footer;
    
        }
        public DialogSection(string header)
        {
            _elements = new List<DialogItem>();
            Header = header;
            Footer = String.Empty;
        }
        public DialogSection()
        {
            _elements = new List<DialogItem>();
            Header = string.Empty;
            Footer = string.Empty;
        }
    
        // enumerator implementation
        public void Clear()
        {
            _elements.Clear();
        }
        public void Add(DialogItem element)
        {
            element.DialogTable = _table;
            element.DialogSection = this;
    
            _elements.Add(element);
        }
        public void Remove(DialogItem element)
        {
            _elements.Remove(element);
        }
        public int IndexOf(DialogItem item)
        {
            return _elements.IndexOf(item);
        }
        public System.Collections.IEnumerator GetEnumerator()
        {
            return _elements.GetEnumerator();
        }
        public int Count
        {
            get { return _elements.Count; }
        }
    
        // indexing
        public DialogItem this [int index] 
        {
            get 
            {
                return _elements[index];
            }
        }
    
        // actual properties
        public string Header 
        {
            get
            {
                return _header;
            }
            set
            {
                _header = value;
            }
        }
        public string Footer 
        {
            get
            {
                return _footer;
            }
            set
            {
                _footer = value;
            }
        }
        public DialogTable Table
        {
            get
            {
                return _table;
            }
            set
            {
                _table = value;
    
                foreach (var item in _elements)
                    item.DialogTable = _table;
            }
        }
    
        // methods
        public void ClearFocus()
        {
            foreach (var element in _elements)
                //if (element.HasFocus())
                    element.Unfocus();
        }
    
        public void RecalculateMetrics()
        {
            VisibleCount = 0;
            foreach (var item in _elements)
            {
                if (item.CellVisible)
                    ++VisibleCount;
            }
        }
        public DialogItem GetVisibleItem(int visibleIndex)
        {
            int index = 0;
            foreach (var item in _elements)
            {
                if (item.CellVisible)
                {
                    if (index == visibleIndex)
                        return item;
                    ++index;
                }
            }
            return null;
        }
        public int VisibleCount
        {
            get;
            set;
        }
    
        private string _header;
        private string _footer;
        private DialogTable _table;
        private List<DialogItem> _elements;
    }
    

    }

    Thursday, July 12, 2018 9:56 AM