
Creating/Generating Read-only and Edit-only Detail Views
#1
Posted 13 December 2014 - 06:52 PM
#2
Posted 14 December 2014 - 02:28 AM
When set to TRUE, the generated user interface elements are required to be placed in ‘Editing Mode’ before the user can modify the generated property controls' values. When not in Editing Mode, all the generated property controls will be put in a read-only state. If the UI was automatically generated by the framework, an ‘Edit’ button will also be automatically added to the navigation bar. Default: FALSE.
code it like:
SCEntityDefinition *myDef = [SCEntityDefinition definitionWithEntityName:@"Entity" ......... myDef.requireEditingModeToEditPropertyValues = YES;
Edited by ozie, 14 December 2014 - 02:30 AM.
- Tarek likes this
P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.
#3
Posted 14 December 2014 - 10:18 AM
Hi Ozie,
Thanks for the suggestion. I tried it and the 'requireEditingModeToEditPropertyValues' property does exactly what you said, and what I asked for; however, that behavior does not generate the outcome I am seeking as it makes everything in the detail view read-only and subject to edit mode to enable user interaction. I realize this behavior is exactly as I requested; but in retrospect what I asked for it is not what I actually need.
Here is some additional detail:
1. My STV-generated detail view has two (SC Object) sections
2. Section 1 contains a 'dashboard' with three sliders and labels that update to show the results of calculations based on slider values
3. Section 2 contains cells with bound properties to my core data model
Right now both sections are displayed in the single detail view. Ideally I would like to:
A. Generate a separate detail view for each section (detail view 1 contains Section 1 content, and detail view 2 contains Section 2 content)
B. Have the master view open detail view 1 (with Section 1 'dashboard' and an Edit button)
C. Have the detail view 1 Edit button open detail view 2 (with Section 2 cells with bound properties)
Is this kind of operation doable with STV? If so, any suggestions on how to approach it are appreciated.
Thanks again Ozie. Thanks for taking the time to help.
#4
Posted 14 December 2014 - 02:47 PM
so something like this with edit buttons to change the slider values etc??
Screen Shot 2014-12-15 at 8.44.58 am.png 48.05K
24 downloads
You can do anything you dream to do with STV:)
P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.
#6
Posted 14 December 2014 - 04:49 PM
sure is doable
P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.
#7
Posted 15 December 2014 - 06:07 AM
#8
Posted 15 December 2014 - 08:59 AM
Hey guys,
It's worth noting here that 'requireEditingModeToEditPropertyValues' is now accessible from Interface Builder. Simply select your Data Definition in IB, then check the 'Require Editing Mode' checkbox.
#9
Posted 19 December 2014 - 12:47 PM
Thanks Tarek and Ozie. I have succeeded in creating the separate views as illustrated in comment #5.
To accomplish this, I created a separate Edit Plan Scene with an associated EditViewController. The EditViewController controller contains a variable identifying the current managed object (bizplan) as shown in the code snippet below:
import UIKit import CoreData class EditViewController: SCTableViewController { var bizplan:Bizplan! @IBAction func updatePlan(sender: AnyObject) { } override func viewDidLoad() { super.viewDidLoad() // Do any additional self.tableViewModsel customizations here println("Edit VC View Did Load - Bizplan: \(bizplan.ideaName)") //<-- correctly prints name of current object let editSection = self.tableViewModel.sectionAtIndex(0) as SCObjectSection //<-- fatal error encountered here editSection.boundObject = bizplan editSection.reloadBoundValues() } }
The bizplan variable is set from the DetailViewController (via "override func prepareForSegue") when the user clicks a "Modify Bizplan Inputs" button that triggers the push of the EditViewController/scene.
When run, the bizplan variable in EditViewController is set properly; however when attempting to assign this variable to the SCObjectSection bound object parameter I am getting a "fatal error: unexpectedly found nil while unwrapping an Optional value". This error occurrs on the "let editSection = self.tableViewModel.sectionAtIndex(0) as SCObjectSection" line.
A screenshot of the storyboard is attached showing the use of SCArrayOfObjects in the Master view and SCObjectSection in the Detail and Edit views.
Storyboard.png 65.85K
20 downloads
Storyboard.png 65.85K
20 downloads
Hopefully this provides sufficient information to suggest a cause and remedy for the fatal error.
Any suggestions are greatly appreciated.
Edited by Donovan Dillon, 19 December 2014 - 12:52 PM.
#10
Posted 20 December 2014 - 11:59 AM
I'm still trying to work this out. I edited viewDidLoad to add some debugging code as shown below:
override func viewDidLoad() { super.viewDidLoad() // Do any additional self.tableViewModsel customizations here let tvModel = self.tableViewModel println("Tableview Sections Count: \(tvModel.sectionCount)") /* let editSection = self.tableViewModel.sectionAtIndex(0) as SCObjectSection editSection.boundObject = bizplan editSection.reloadBoundValues() */ }
Here is what I discovered:
tvModel.sectionCount does not register SCObjectSection addition(s) to the tableview -- but it does register the proper count of SCArrayOfObjectSection when they are added to the tableview.
That is why "let editSection = self.tableViewModel.sectionAtIndex(0) as SCObjectSection" returns nil.
Three questions:
1. Is this an STV bug? I am using STV 4.0.5.
2. Am I correct in using SCObjectSection to present the bound object for editing? If not, what STV class/facility should I use?
3. Am I using the correct event/controller (viewDidLoad in EditViewController) to set the bound object?
As always, any suggestions are appreciated.
Thanks!
#11
Posted 21 December 2014 - 10:01 PM
Problem solved -- with ozie's help!
The problem was ultimately caused by improperly setting the Parent Entity attribute (to the Parent Entity) for three child entities in my core data model. The attribute should have been left at the default value of "No Parent Entity."
With this change and viewDidLoad as follows the code is working as desired with read-only detail view and edit-only edit view.
override func viewDidLoad() { super.viewDidLoad() // Do any additional self.tableViewModel customizations here let tvModel = self.tableViewModel let editSection = self.tableViewModel.sectionAtIndex(0) as SCObjectSection editSection.boundObject = bizplan as Bizplan editSection.reloadBoundValues() tvModel.reloadBoundValues() tvModel.tableView.reloadData() }
I will have to experiment to see if it all three reload lines are necessary; but for now works like a charm.
Thanks again ozie!
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users