ra1028 / former Goto Github PK
View Code? Open in Web Editor NEWFormer is a fully customizable Swift library for easy creating UITableView based form.
License: MIT License
Former is a fully customizable Swift library for easy creating UITableView based form.
License: MIT License
its possible to enable editActionsForRowAtIndexPath??
It looks like removeRowFormer always marks the inline row for deletion, even when it is not active.
Any idea, how to use UITableViewRowActions in this? I don't think its supported.
Hi @ra1028 , first of all, thanks for good library,
if i open formViewController for the first time, it's waiting for 2-3 seconds, and then opens view controller, can we avoid this issue?
I am developing app for ipad 2 generation, and this is really issue.
let header = LabelViewFormer<FormLabelHeaderView>() { view in
view.titleLabel.text = "Label Header"
}
let section = SectionFormer(rowFormer: labelRow, inlinePickerRow)
.set(headerViewFormer: header)
LabelViewFormer.update
is implemented like this:
open override func update() {
super.update()
view.formTitleLabel().text = text
}
Which means that the text is overridden by the text
set in LabelViewFormer
.
The correct usage would be:
let header = LabelViewFormer<FormLabelHeaderView>() { _ in }
header.text = "Label Header"
let section = SectionFormer(rowFormer: labelRow, inlinePickerRow)
.set(headerViewFormer: header)
But I'd argue it's LabelViewFormer
that should be changed.
Dear Sir,
I just cloned git checkout tags/1.3.0 repo to run examples but I am getting 28 errors.
../Former/Former/Commons/FormerProtocol.swift:22:5: Expected declaration
../Former/Former/RowFormers/SliderRowFormer.swift:53:51: Expected expression in list of expressions
It must be something missing from my end. Can you please help me how to run the examples so I can learn this awesome lib?
When I use former.insertUpdate(rowFormer: someRow, below: otherRow, rowAnimation: .top)
it inserts someRow
empty space even it already inserted.
I cannot even call myself a developer yet, b/c I'm still brand new... so please forgive me for this....
When I Run Former and even Former Demo, it builds but there's no Simulator or even a Storyboard that I can find... I thought I was going to be able to see examples.
Thank you!
Would be great if this project could be installed via carthage.
I'm fetching data from a realm model.
let industries = realm.objects(Industry)
Then I try to define a list of InlinePickerItem
from it:
$0.pickerItems = industries.map({ industry in
return InlinePickerItem(title: industry.name, value: industry.id)
})
But XCode keeps saying: Cannot convert value of type 'Int' to expected argument type '_?'
, pointing to industry.id
.
Am I missing something?
It would be nice to be able to override this function!
Currently only text is exposed. it will be great to expose attributed text, so FontAwesome icons can be placed in front of label.
Thanks!
My Code:
private let itemDateTime = InlineDatePickerRowFormer<FormInlineDatePickerCell>() {
$0.titleLabel.text = "Data (Date & Time)"
$0.titleLabel.textColor = .formerColor()
$0.titleLabel.font = .boldSystemFont(ofSize: 15)
$0.displayLabel.textColor = .formerSubColor()
$0.displayLabel.font = .systemFont(ofSize: 15)
}.inlineCellSetup {
$0.datePicker.datePickerMode = .dateAndTime
}.displayTextFromDate(String.mediumDateShortTime)
private let itemNumber = StepperRowFormer<FormStepperCell>(){
$0.titleLabel.text = "Data (Number)"
$0.titleLabel.textColor = .formerColor()
$0.titleLabel.font = .boldSystemFont(ofSize: 15)
$0.displayLabel.textColor = .formerSubColor()
$0.displayLabel.font = .systemFont(ofSize: 15)
}.displayTextFromValue { "\(Int($0))" }
private func addStoredDataRow(_ newRow:String,belowRow row: RowFormer){
self.former.insertUpdate(rowFormers: [itemDateTime as RowFormer], below: row, rowAnimation: .fade)
}
private func removePreviousStoreDataRow(){
self.former.removeUpdate(rowFormers: [itemDateTime as RowFormer], rowAnimation: .fade)
}
It returns this error
** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 5 from section 0 which only contains 5 rows before the update'
*** First throw call stack:
(
0 CoreFoundation 0x000000010dbb7d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010b4e021e objc_exception_throw + 48
2 CoreFoundation 0x000000010dbbbe42 +[NSException raise:format:arguments:] + 98
3 Foundation 0x000000010b07566d -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 UIKit 0x000000010baebc81 -[UITableView _endCellAnimationsWithContext:] + 6554
5 Former 0x000000010ab80fed _TFC6Former6Former12removeUpdatefT10rowFormersGSaCS_9RowFormer_12rowAnimationOSC23UITableViewRowAnimation_DS0_ + 717
6 Help me remember 0x000000010a906461 _TFC16Help_me_remember21AddNoteViewControllerP33_77E2466EC3256EA1B6E259688F5902C826removePreviousStoreDataRowfT_T_ + 401
7 Help me remember 0x000000010a906060 _TFFC16Help_me_remember21AddNoteViewControllerP33_77E2466EC3256EA1B6E259688F5902C89configureFT_T_U8_FGC6Former16InlinePickerItemP__T_ + 624
8 Former 0x000000010abaec6f _TTRG0_RxCSo15UITableViewCellx6Former23InlinePickerFormableRowrXFo_oGCS0_16InlinePickerItemq____XFo_iGS2_q___iT__ + 31
9 Former 0x000000010abb3c63 _TPA__TTRG0_RxCSo15UITableViewCellx6Former23InlinePickerFormableRowrXFo_oGCS0_16InlinePickerItemq____XFo_iGS2_q___iT__ + 131
10 Former 0x000000010abb312e _TFC6Former21InlinePickerRowFormerP33_6A299C3DDCBB01395AC4594859BB2B0B12valueChangedfT10pickerItemGCS_10PickerItemq___T_ + 2398
11 Former 0x000000010abb50ea _TPA + 26
12 Former 0x000000010abb876f _TTRG0_RxCSo15UITableViewCellx6Former17PickerFormableRowrXFo_oGCS0_10PickerItemq____XFo_iGS2_q___iT__ + 31
13 Former 0x000000010abb8853 _TPA__TTRG0_RxCSo15UITableViewCellx6Former17PickerFormableRowrXFo_oGCS0_10PickerItemq____XFo_iGS2_q___iT__ + 131
14 Former 0x000000010abb97b5 _TFC6FormerP33_EABB0162137B5A80359DB051B72B0E158Observer10pickerViewfTCSo12UIPickerView12didSelectRowSi11inComponentSi_T_ + 405
15 Former 0x000000010abb984a _TToFC6FormerP33_EABB0162137B5A80359DB051B72B0E158Observer10pickerViewfTCSo12UIPickerView12didSelectRowSi11inComponentSi_T_ + 74
16 UIKit 0x000000010b9930fd -[UIPickerView _sendSelectionChangedForComponent:notify:] + 104
17 UIKit 0x000000010b99334e -[UIPickerView _sendSelectionChangedFromTable:notify:] + 370
18 UIKit 0x000000010c1603de -[UIPickerTableView _scrollingFinished] + 187
19 UIKit 0x000000010c1605ce -[UIPickerTableView scrollViewDidEndDecelerating:] + 30
20 UIKit 0x000000010baa043d -[UIScrollView(UIScrollViewInternal) _scrollViewDidEndDeceleratingForDelegate] + 91
21 UIKit 0x000000010ba9cf7e -[UIScrollView(UIScrollViewInternal) _stopScrollDecelerationNotify:] + 316
22 UIKit 0x000000010ba9d1d5 -[UIScrollView(UIScrollViewInternal) _stopScrollingNotify:pin:tramplingDragFlags:] + 505
23 UIKit 0x000000010ba9511f -[UIScrollView _smoothScrollWithUpdateTime:] + 3304
24 QuartzCore 0x0000000113778895 _ZN2CA7Display15DisplayLinkItem8dispatchEy + 57
25 QuartzCore 0x0000000113778755 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 449
26 CoreFoundation 0x000000010db49db4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
27 CoreFoundation 0x000000010db49a43 __CFRunLoopDoTimer + 1075
28 CoreFoundation 0x000000010db495ca __CFRunLoopDoTimers + 250
29 CoreFoundation 0x000000010db412f1 __CFRunLoopRun + 2065
30 CoreFoundation 0x000000010db40884 CFRunLoopRunSpecific + 420
31 GraphicsServices 0x0000000113751a6f GSEventRunModal + 161
32 UIKit 0x000000010b9afc68 UIApplicationMain + 159
33 Help me remember 0x000000010a90c1df main + 111
34 libdyld.dylib 0x000000010f1ab68d start + 1
35 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I'm sure my code works well as if i replace itemDateTime
with itemNumber
it works well with removing and inserting multiple times.
Sorry I am still learning swift so I can't help with debugging it.
I am trying to make a TextFieldRowFormer the default selection for the form, so that the keyboard is up and ready when the form appears.
I have tried both row.cell.textField.becomeFirstResponder()
and
let rowToSelect: NSIndexPath = NSIndexPath(forRow: 0, inSection: 0);
tableView.selectRowAtIndexPath(rowToSelect, animated: true, scrollPosition: UITableViewScrollPosition.None)
...but neither seems to trigger selection of the row. Am I missing something obvious?
I think we should put an option that we can change the style of the tableview and the tableview should be a var to easy to change value of the property.
How can I detect whether a user has chosen a particular item in the pickerview? More specifically, when a user chooses an item in the inlinepicker view, I want to invoke a function call and use those results in the function. I tried calling the function in the .OnValueChanged closure but have been getting issues regarding namespace. Can someone give me an example of how to achieve this?
Thanks a lot!
SignInVC.swift:43:28: Property 'tableView' with type 'UITableView?' cannot override a property with type 'UITableView'
Is it possible to use Former in combination with TableView prototype cells? As in instantiating rows using table.dequeueReusableCellWithIdentifier?
Hi,
I'm addressing an issue when I try to set an image for the cell's default imageView
my code is:
` // MARK: Protection
let protectionHeader = LabelViewFormer<FormLabelHeaderView>() {
$0.contentView.backgroundColor = .clearColor()
}.configure {
$0.viewHeight = 80
$0.text = "Protezione"
}
let protectionFooter = LabelViewFormer<FormLabelFooterView>() {
$0.contentView.backgroundColor = .clearColor()
}.configure {
$0.viewHeight = 80
$0.text = "Abilitando questa funzione, l'accesso all'app sarà verificato tramite Touch ID."
}
let touchIDRow = SwitchRowFormer<FormSwitchCell>() {
$0.titleLabel.text = "Touch ID"
$0.imageView?.image = UIImage(named: "icon_touchid")
$0.switchButton.onTintColor = UIColor(red: 0.9, green: 0.55, blue: 0.08, alpha: 1)
} .configure {
$0.switched = PA.sharedInstance.touchIDProtection
}.onSwitchChanged { switched in
PA.sharedInstance.touchIDProtection = switched
}
let protectionSection = SectionFormer(rowFormer: touchIDRow)
.set(headerViewFormer: protectionHeader)
.set(footerViewFormer: protectionFooter)`
I think that should be fixed :)
Here is what I have been seeing. I have an inline picker with color in the title. When I select the row it shows the picker. However when it closes up the color in the Title goes back to solid black.
let zone1HRRow = InlinePickerRowFormer<FormInlinePickerCell, Any>() {
$0.titleLabel.attributedText = self.attributedZoneString(z1Text: “1”,
z1Color: UIColor.HRZones.hrZone1.colorValue,
z2Text: “2”,
z2Color: UIColor..HRZones.hrZone2.colorValue)
$0.displayLabel.textColor = Color.black
$0.displayLabel.font = self.detailLabelFont
$0.backgroundColor = Color.grey.lighten2
}.configure {
$0.pickerItems = (40...200).map { InlinePickerItem(title: “\($0) \(bpmString)”, value: Int($0)) }
$0.displayEditingColor = Color.red.darken2
}
zone1HRRow.onUpdate { (picker: InlinePickerRowFormer<FormInlinePickerCell, Any>) in
picker.selectedRow = UserConfig.sharedConfig.hrZoneOne - 40
}
Want to write login to add new RowFormer to section but need to check if there is already the same RowFormer.
kinda:
former.rowFormers.contains(where: <#T##(RowFormer) throws -> Bool#>)
Can we have in objective-C language. Former profile implementation,
I was wondering if we could have an option to update the header background color, to match other UI color schemes?
Something like...
let infoSection = SectionFormer(rowFormer: infoRow).set(headerViewFormer: “Information”, background: UIColor.whiteColor() )
Hello,
I'm trying to customize the appearance of my table. I set the backgroundColor to a different grey, however my headers have the previous background color with no apparent way to change it. Am I missing something or do I have to create a custom view just to change the background?
Does anyone know if it is possible or best way to implement disabling of individual rows?
Update - Best reference I have found is: https://github.com/ra1028/Former/blob/master/Former-Demo/Former-Demo/Controllers/DefaultsViewController.swift
Is there a way to get all value of the form as array or nsDICTIONARY? how can i get all the value to call a rest api?
I'm trying to create a Delete button row, by using a FormLabelCell and then setting the textAlignment to be centered and the textColor to be red. However, those changes don't seem to be working. I'm creating my section like this
let deleteSection = SectionFormer().append(rowFormer: LabelRowFormer<FormLabelCell>()
.configure { row in
row.text = "Delete"
row.cell.textLabel?.textAlignment = .center
row.cell.textLabel?.textColor = .red
}.onSelected { row in
if let indexPath = self.tableView.indexPath(for: row.cell) {
self.tableView.deselectRow(at: indexPath, animated: true)
}
self.startDeleteWorkflow()
})
self.former.append(sectionFormer: deleteSection)
When I run this, I get a FormLabelCell, but the "Delete" text is still left aligned and black, not red and centered. Any ideas?
Can't update section header text. I tried:
someHeader.text = "New Title".uppercased()
and:
someHeader.configure { view in
view.text = "New Title".uppercased()
}
also tried:
someHeader.viewUpdate { view in
view.text = "New Title".uppercased()
}
Hi,
I want to show a segmented control without selection at creation (but not momentary). So, I've specified the attribute "selectedIndex" with the value "UISegmentedControlNoSegment". But, when i click for the first time on the segmented control, the app crash :
Former-Demo[45492:7325632] **\* Terminating app due to uncaught exception 'NSRangeException', reason: '**\* -[**NSArrayM objectAtIndex:]: index 18446744073709551615 beyond bounds [0 .. 1]'
**\* First throw call stack:
(
0 CoreFoundation 0x000000010cfd5f45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010ef21deb objc_exception_throw + 48
2 CoreFoundation 0x000000010ceb99e4 -[__NSArrayM objectAtIndex:] + 212
3 UIKit 0x000000010dc33cc3 -[UISegmentedControl titleForSegmentAtIndex:] + 38
4 Former 0x000000010cd94e6b _TFC6Former18SegmentedRowFormerP33_5319F26570932CABE1649D3998AD612D12valueChangeduRdq_CSo15UITableViewCellq_S_20SegmentedFormableRow_fGS0_q__FCSo18UISegmentedControlT_ + 155
5 Former 0x000000010cd9512a _TToFC6Former18SegmentedRowFormerP33_5319F26570932CABE1649D3998AD612D12valueChangeduRdq_CSo15UITableViewCellq_S_20SegmentedFormableRow_fGS0_q__FCSo18UISegmentedControlT_ + 74
6 UIKit 0x000000010da1be91 -[UIApplication sendAction:to:from:forEvent:] + 92
7 UIKit 0x000000010db874d8 -[UIControl sendAction:to:forEvent:] + 67
8 UIKit 0x000000010db877a4 -[UIControl _sendActionsForEvents:withEvent:] + 311
9 UIKit 0x000000011bfc2791 -[UISegmentedControlAccessibility sendActionsForControlEvents:] + 39
10 UIKit 0x000000010dc34661 -[UISegmentedControl _setSelectedSegmentIndex:notify:animate:] + 690
11 UIKit 0x000000010dc36d35 -[UISegmentedControl touchesEnded:withEvent:] + 232
12 UIKit 0x000000010deed9ba _UIGestureRecognizerUpdate + 10279
13 UIKit 0x000000010da899c0 -[UIWindow _sendGesturesForEvent:] + 1137
14 UIKit 0x000000010da8abf6 -[UIWindow sendEvent:] + 849
15 UIKit 0x000000010da3a2fa -[UIApplication sendEvent:] + 263
16 UIKit 0x000000011bfbda29 -[UIApplicationAccessibility sendEvent:] + 77
17 UIKit 0x000000010da14abf _UIApplicationHandleEventQueue + 6844
18 CoreFoundation 0x000000010cf02011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION** + 17
19 CoreFoundation 0x000000010cef7f3c __CFRunLoopDoSources0 + 556
20 CoreFoundation 0x000000010cef73f3 __CFRunLoopRun + 867
21 CoreFoundation 0x000000010cef6e08 CFRunLoopRunSpecific + 488
22 GraphicsServices 0x0000000112513ad2 GSEventRunModal + 161
23 UIKit 0x000000010da1a30d UIApplicationMain + 171
24 Former-Demo 0x000000010cbf9fad main + 109
25 libdyld.dylib 0x000000010fa2992d start + 1
26 ??? 0x0000000000000001 0x0 + 1
The crash can be simulated by adding the line $0.selectedIndex = UISegmentedControlNoSegment
in the ExampleViewController (line 95).
Could you have a look ?
Thx !
SelecterPickerFormableRow should be SelectorPickerFormableRow in the docs.
I subclass from FormViewController
and configure former
When I pop this controller, deinit
is not called
Is it some way to remove my ViewController
from memory?
I'm new to swift and started using Former and was wondering why:
let header = LabelViewFormer<FormLabelHeaderView>() { view in
dispatch_async(dispatch_get_main_queue()) {
view.titleLabel.text = "Label Header"
}
}
Works versus using:
let header = LabelViewFormer<FormLabelHeaderView>() { view in
view.titleLabel.text = "Label Header"
}
Which doesn't seem to work.
When I don't force it on the main queue, the label text just doesn't show up. I'm using the following controller set up:
class SettingsViewController: UIViewController {
/**
* Settings table
*/
@IBOutlet weak var table: UITableView!
/**
* Form framework
*/
internal lazy var former: Former = Former(tableView: self.table)
/**
* Initiate controller and tab title
*/
required init?(coder aDecoder: (NSCoder!)) {
super.init(coder: aDecoder)
title = "Settings"
}
And then basically running the 'Simple example' code from the README.md in the viewDidLoad of the controller.
So I got it to work using the main queue, but I don't fully understand why the closure is run in a different queue?
I have tried both row.cell.textField.becomeFirstResponder()
and
let rowToSelect: NSIndexPath = NSIndexPath(forRow: 0, inSection: 0);
tableView.selectRowAtIndexPath(rowToSelect, animated: true, scrollPosition: UITableViewScrollPosition.None)
...but neither seems to trigger selection of the row. Am I missing something obvious?
Hi, i have this code that works fine:
private func switchInfomationSectionDate() { if moreInformationDate == true { former.insertUpdate(rowFormer: allDayRow!, below: moreDate!) former.insertUpdate(rowFormer: locationRow!, below: allDayRow!) former.insertUpdate(rowFormer: selectAddressRow!, below: locationRow!) } else { former.removeUpdate(rowFormers: [allDayRow!,locationRow!,selectAddressRow!],rowAnimation:.Top) eventDetails["date_start"] = "" eventDetails["date_end"] = "" } }
i i change one rowFormer, for example: selectAddressRow and i put a datePickerRow
endRow = InlineDatePickerRowFormer<FormInlineDatePickerCell>() { $0.titleLabel.text = "Fine" $0.titleLabel.font = .boldSystemFontOfSize(15) $0.displayLabel.font = .systemFontOfSize(15) .displayTextFromDate(String.mediumDateShortTime) }
the row is correctly added, but when i call switchInfomationSectionDate again i obtain:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to delete row 4 from section 2 which only contains 4 rows before the update'
*** First throw call stack:
Only with this type of row, any ideas?
How do you make the search controller work with former?
Any chance to have a swift 3.0 version? Its a fantastic project!
Former-Demo/Former-Demo/Controllers/AddEventViewController.swift line:28
case Daily: return "Dayly"
Should be:
case Daily: return "Daily"
can i manually enable and disable the userinteraction of cell
Hi,
Maybe I'm missing something but I'm having some troubles refreshing the pickerItems
on a InlinePickerRowFormer
My goal is to load different items in a InlinePickerRowFormer
based on the selection of another InlinePickerRowFormer
I've tried removing and adding items calling update()
on the row and self.somerow.former?.reload(rowFormer: self.otherrow)
but both seem to ignore the capacity and aren't showing the option correctly.
So basically I'm wondering what the correct way is, for refreshing the pickerItems
on a InlinePickerRowFormer
No description provided.
In swift 3, if I don't set this method to public, my custom (non xib) cell classes fall over when the rowFormer tries to create them
The same applies to FormHeaderFooterView
Hi there,
Relatively new to Swift and hoping someone may have had luck setting up the default ProfileFieldCell to accept two UITextFields as inputs. I saw the sample code provided, but was not able to seem to get it running.
Any help is greatly appreciated, thanks a bunch! :)
I am using each section to display one model, so every time the view controller loads it will fetch the current models that I want to display. So I'd like to remove all the sections in viewWillAppear
before I populate it with the filtered models.
But when I try adding the former.removeAll()
method, it gives me this error fatal error: Index out of range
This is what my viewWillAppear
looks like
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(true)
former.removeAll()
Client.sharedClient.fetchUserOwnedSessions { (success, sessions) in
if success {
self.addSections(sessions)
}
}
}
due to a missing reload of the picker, a setting of a selected item of the picker is not shown.
In file PickerRowFormer.swift the following line must be added after line let picker = cell.formPickerView()
:
picker.reloadAllComponents()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.