10 Answers, 1 is accepted
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
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;
}
}
}
}
Can you confirm that your TKDataFormViewController subclass is inside UINavigationController?
Regards,
Adrian
Telerik
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;
}
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
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