Имам това, което вярвам, че е доста ясен клас Monotouch.Dialog.
public partial class EditAccountDialog : DialogViewController
{
Section emailSection;
Section passwordSection;
Section profileSection;
Section addressSection;
EntryElement emailEntry;
EntryElement passwordEntry;
EntryElement password2Entry;
EntryElement firstNameEntry;
EntryElement lastNameEntry;
EntryElement phoneNumberEntry;
EntryElement streetEntry;
EntryElement street2Entry;
EntryElement cityEntry;
EntryElement stateEntry;
EntryElement zipEntry;
public EditAccountDialog(bool pushing) : base (UITableViewStyle.Grouped, null, pushing)
{
emailEntry = new EntryElement(null, "[email protected]", String.Empty);
passwordEntry = new EntryElement (null, "Password", String.Empty, true);
password2Entry = new EntryElement (null, "Re-enter password", String.Empty, true);
firstNameEntry = new EntryElement ("First Name", "First Name", String.Empty);
lastNameEntry = new EntryElement ("Last Name", "Last Name", String.Empty);
phoneNumberEntry = new EntryElement ("Phone Number", "###-###-####", String.Empty);
streetEntry = new EntryElement ("Street", "#### Any St.", String.Empty);
street2Entry = new EntryElement ("Street 2", "Apt #", String.Empty);
cityEntry = new EntryElement ("City", "City", String.Empty);
stateEntry = new EntryElement ("State", "State", String.Empty);
zipEntry = new EntryElement ("ZIP Code", "#####", String.Empty);
emailSection = new Section ("Email"){
emailEntry,
};
passwordSection = new Section ("Password"){
passwordEntry,
password2Entry,
};
profileSection = new Section("Profile") {
firstNameEntry,
lastNameEntry,
phoneNumberEntry,
};
addressSection = new Section("Address") {
streetEntry,
street2Entry,
cityEntry,
stateEntry,
zipEntry,
};
Root = new RootElement("Edit Account") {
emailSection,
passwordSection,
profileSection,
addressSection,
};
}
public virtual void HandleGetAccountResponse(GetAccountResponse response)
{
emailEntry.Value = response.Email;
firstNameEntry.Value = response.FirstName;
lastNameEntry.Value = response.LastName;
phoneNumberEntry.Value = response.Phone;
streetEntry.Value = response.StreetAdd;
street2Entry.Value = response.StreetAdd2;
cityEntry.Value = response.City;
stateEntry.Value = response.State;
zipEntry.Value = response.Zip;
}
}
След като страницата се зареди, асинхронно извиквам REST API за информация за съществуващ акаунт, който след това извиква HandleGetAccountResponse
по-горе, за да попълни предварително всеки EntryElement
в диалоговия прозорец.
Проверявам REST отговора и знам, че получавам всички необходими данни. Проблемът, с който се сблъсквам, е, че една или две произволни клетки на тази страница изглеждат празни, дори след като стойностите им са зададени. Например полетата Zip и City може да изглеждат празни.
Още по-объркващо е, че ако превъртя до дъното и видя, че полетата Zip и City са празни, след това превъртя докрай нагоре, след това превъртя отново до дъното, различен набор от клетки може да са празни, като Street2 и State.
Очевидно това не е нормално поведение за Monotouch.Dialog или никой не би го използвал. Какво мога да направя, за да разреша този проблем?