This is a migrated thread and some comments may be shown as answers.
Xamarian iOS Values Provider
10 Answers 28 Views
This is a migrated thread and some comments may be shown as answers.
jon
Top achievements
Rank 1
jon asked on 24 Dec 2015, 06:19 AM
I'm trying to follow the examples for the iOS Xamarin TKDataForms. How do you get the value providers, say for the EncryptionLevel property in the DataFormGettingStarted example, to push to another view? I'm trying to add this to an app and mine isn't pushing to the new a view like the example is. Is there other code that is required for the push of the new view controller or is it done when I assign the value in the value provider?  

10 Answers, 1 is accepted

Sort by
0
jon
Top achievements
Rank 1
answered on 28 Dec 2015, 12:09 PM
Also, I'm using sliding panel setup for the app; with a left panel menu, a center panel content, and an optional right panel for whatever. The center panel is a UINavigationController with the desired ViewController. Could this be what's throwing off the value provider? If so, how do I make it recognize the center panel navigation controller and push a new list view of the value provider? 
0
Accepted
Adrian
Telerik team
answered on 28 Dec 2015, 12:19 PM
Hello, Jon,

Thank you for contacting us.

To show the values for the property in a separate view the view controller that holds the data form should inherit from TKDataFormViewController and you should use a UINavigationController as a container controller. Then you should set editorClass of the TKEntityProperty to be TKDataFormOptionsEditor. Please consider the code snippet below:
public class DataFormGettingStarted : TKDataFormViewController
{
    public override void ViewDidLoad()
    {
        base.ViewDidLoad ();
        // ...
        this.dataSource["EncryptionLevel"].ValuesProvider = NSArray.FromStrings(new string[] { "FIPS Compliant", "High", "Client Compatible", "Low" });
        this.dataSource["EncryptionLevel"].EditorClass = new Class(typeof(TKDataFormOptionsEditor));
        // ...
    }
}

I hope this helps. If you need further assistance do not hesitate to contact us.

Regards,
Adrian
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
jon
Top achievements
Rank 1
answered on 31 Dec 2015, 03:54 AM
Attached is a sample of the issue I'm having
0
jon
Top achievements
Rank 1
answered on 31 Dec 2015, 04:06 AM

Still not working. I have a model field:

[Export("TimeZone")]
public byte TimeZone { get; set; }

 And my View Controller:

namespace Test
{
    public partial class ViewController : TKDataFormViewController
    {
        TKDataForm dataForm;
        TKDataFormEntityDataSourceHelper dataSource;
        DataFormDelegate dataFormDelegate;
        m_Account mobileAccount;
        UIButton btnSaveAccount;

        public ViewController ()
        {
            Title = "Example";
            mobileAccount = new m_Account ();
        }

        public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();
            View.BackgroundColor = UIColor.White;

            //Account table
            this.dataSource = new TKDataFormEntityDataSourceHelper (this.mobileAccount);
            this.dataFormDelegate = new DataFormDelegate ();

            this.dataForm = new TKDataForm ();
            this.dataForm.Frame = new CGRect (0, this.NavigationController.NavigationBar.Bounds.Height, View.Bounds.Width, View.Bounds.Height - 66);
            this.dataForm.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            this.dataForm.BackgroundColor = UIColor.White;

            this.dataSource ["TimeZone"].DisplayName = "Time Zone";

            //Timezone is a byte coming from the api
            this.dataSource ["TimeZone"].ValuesProvider = NSArray.FromStrings (new string[] {"Central","Mountain","Pacific","Eastern"});
            this.dataSource["TimeZone"].EditorClass = new ObjCRuntime.Class(typeof(TKDataFormOptionsEditor));

            this.dataSource.AddGroup (" ", new string[] {
                "TimeZone"
            });

            this.dataForm.Delegate = this.dataFormDelegate;
            this.dataForm.WeakDataSource = this.dataSource.NativeObject;
            this.dataForm.CommitMode = TKDataFormCommitMode.Immediate;


            btnSaveAccount = new UIButton (new CGRect (0, this.dataForm.Frame.Size.Height, this.View.Bounds.Width, 66));
            btnSaveAccount.SetTitle ("Save My Account", UIControlState.Normal);
            btnSaveAccount.BackgroundColor = UIColor.Green;
            btnSaveAccount.SetTitleColor (UIColor.White, UIControlState.Normal);
            btnSaveAccount.AddTarget (this, new ObjCRuntime.Selector ("saveMyAccount"), UIControlEvent.TouchUpInside);

            View.AddSubview (this.dataForm);
            View.AddSubview (btnSaveAccount);
        } 

        [Export ("saveMyAccount")]
        void saveMyAccount()
        {
        }
    }

    class DataFormDelegate : TKDataFormDelegate
    {
        public override void UpdateEditor (TKDataForm dataForm, TKDataFormEditor editor, TKEntityProperty property)
        {
            if (property.Name == "TimeZone") {
                editor.TextLabel.TextColor = UIColor.Black;
                editor.BackgroundColor = UIColor.Clear;
                ((TKDataFormOptionsEditor)editor).SelectedOptionLabel.TextColor = UIColor.Black;
                ((TKDataFormOptionsEditor)editor).SelectedOptionLabel.TextAlignment = UITextAlignment.Left;
            }
        }
    }
}

 

0
Adrian
Telerik team
answered on 04 Jan 2016, 09:12 AM
Hi, Jon,

Can you confirm that your TKDataFormViewController subclass is inside UINavigationController?

Regards,
Adrian
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
jon
Top achievements
Rank 1
answered on 04 Jan 2016, 09:20 AM

Yes I can, here is my app delegate file. I'm using a sliding panel component with a left, middle, and optional right view. The content is being loaded into the center panel for the data form.

public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
        {
            JASidePanelController viewController = new JASidePanelController();
            viewController.ShouldDelegateAutorotateToVisiblePanel = false;
            viewController.CenterPanel = new UINavigationController (new ViewController ());
            viewController.LeftPanel = new UINavigationController (new MenuViewController ());

            this.Window = new UIWindow (UIScreen.MainScreen.Bounds);
            this.Window.RootViewController = viewController;
            this.Window.MakeKeyAndVisible ();

            return true;
        }

0
jon
Top achievements
Rank 1
answered on 04 Jan 2016, 09:23 AM
What's even weirder is if I use the EncryptionLevel example from above, it works. The only difference is my model is a byte instead of an int but if I change my model property to an int, it still doesn't work for my example with time zones.
0
Adrian
Telerik team
answered on 05 Jan 2016, 03:20 PM
Hi, Jon, 

I am not able to reproduce this issue. Could you please send me a sample project that can be compiled and the issue occurs so I could investigate it further and provide you with a solution?

I am looking forward to your reply.

Regards,
Adrian
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
jon
Top achievements
Rank 1
answered on 08 Jan 2016, 10:00 AM
I found the issue. I was instantiating a new data form instead of using the virtual class. Thanks
0
Adrian
Telerik team
answered on 11 Jan 2016, 04:07 PM
Hi, Jon,

Thank you for the feedback. I am glad that the issue is solved.
If you have further questions, do not hesitate to contact us.

Regards,
Adrian
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
jon
Top achievements
Rank 1
Answers by
jon
Top achievements
Rank 1
Adrian
Telerik team
Share this question
or