IBAForms

74 views
Skip to first unread message

Benjamin Parrish

unread,
Mar 19, 2013, 9:56:34 PM3/19/13
to ibaf...@googlegroups.com
I have presented a form, but all of my fields seem to be readonly, what have I missed?  I am definitely going to kick myself later for not being able to recognize something simple.  And as a side note -- How can I make the view have a clear background?

DataSource

IBAFormSection * taskSection = [self addSectionWithHeaderTitle:@"Enter new task" footerTitle:nil];

        

        [taskSection addFormField:[[IBATextFormField alloc] initWithKeyPath:kTask title:@"Task"]];

        

        NSArray *dayOptions = [IBAPickListFormOption pickListOptionsForStrings:[NSArray arrayWithObjects:

                                                                                       @"Sunday",

                                                                                       @"Monday",

                                                                                       @"Tuesday",

                                                                                       @"Wedneasday",

                                                                                       @"Thursday",

                                                                                       @"Friday",

                                                                                       @"Saturday",

                                                                                       nil]];

IBASingleIndexTransformer *dayTransformer = [[IBASingleIndexTransformer alloc] initWithPickListOptions:dayOptions];

[taskSection addFormField:[[IBAPickListFormField alloc] initWithKeyPath:kDay

                                                                             title:@"Day"

                                                                  valueTransformer:dayTransformer

                                                                     selectionMode:IBAPickListSelectionModeSingle

                                                                           options:dayOptions]];

        

        NSArray *timeOptions = [IBAPickListFormOption pickListOptionsForStrings:[NSArray arrayWithObjects:

                                                                                         @"1 Minute",

                                                                                         @"2 Minute",

                                                                                         @"3 Minute",

                                                                                         @"4 Minute",

                                                                                         @"5 Minute",

                                                                                         nil]];

IBASingleIndexTransformer *timeTransformer = [[IBASingleIndexTransformer alloc] initWithPickListOptions:timeOptions];

[taskSection addFormField:[[IBAPickListFormField alloc] initWithKeyPath:kTimeRequired

                                                                             title:@"Time"

                                                                  valueTransformer:timeTransformer

                                                                     selectionMode:IBAPickListSelectionModeSingle

                                                                           options:timeOptions]];


FormViewController


- (void)loadView

{

[super loadView];

    

UIView *view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

[view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];

UITableView *formTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] bounds] style:UITableViewStyleGrouped];

[formTableView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];

[self setTableView:formTableView];

[view addSubview:formTableView];

[self setView:view];

}


- (void)viewDidLoad

{

    TaskDataSource *dataSource = [[TaskDataSource alloc] initWithModel:_task];

    

    [self setFormDataSource: dataSource];

    

    self.tableView.backgroundColor = [UIColor clearColor];

    

    self.tableView.separatorColor = [UIColor colorWithHexString:@"0033FF"];

    

    self.title = @"Add Task";

}

Oliver Jones

unread,
Mar 20, 2013, 6:08:13 AM3/20/13
to ibaf...@googlegroups.com
All UIViews start out with backgroundColor set to nil which is effectively clear.  

Some subclasses of UIView like UILabel have a default backgroundColor that is not nil.  In the case of UILabel it is white.

If you want to specifically set a view's background color to 'clear' you can use view.backgroundColor = [UIColor clearColor];

Also, reading your code.  You are overloading loadView.  You should never call [super loadView] unless you're subclassing a specific class that expects it.  UIViewController does not and in fact will create a view hierarchy and do some other unnecessary stuff if you call super.  So don't.  It is wasted work (and may have side effects).

Note that on iPad you need to also set UITableView's backgroundView to nil to make a table transparent.  Good practice to do it on iPhone too.

Not sure what your key problem is though with readonly form fields.  It has been an age since I did anything with IBAForms.

Even here at IBA HQ we're generally using and recommending EZForm written by our good friend Chris Miles.  https://github.com/chrismiles/EZForm

It is a more modern code base and less reliant on UITableView.

Regards

--
You received this message because you are subscribed to the Google Groups "IBAForms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ibaforms+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages