filipealva / pickerview Goto Github PK
View Code? Open in Web Editor NEW🔸 A customizable alternative to UIPickerView in Swift.
License: MIT License
🔸 A customizable alternative to UIPickerView in Swift.
License: MIT License
Is there a way to programmatically scroll to a row or index, after the picker has loaded?
I need to scroll to specific items, after the view has loaded, based on what the user selects in that View Controller
I've tried objectPicker.currentSelectedRow = 0
Any help is appreciated.
I want to add two components on your picker view.
Example:
A | 1
B | 2
C | 3
Hi !
I meet a strange problem that "sometimes" it will crash due to beyond the data array.
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
and the " bounds[0..1] " will be different every time, sometimes it's [0..0], sometimes it's [0..2] and [0..3],
hope you can help me !
This project is amazing! It's very cool believe me!
Maybe is possible have a version in objective.c or a demo project how to implement swift in objective.c?Many now use swift but I'm not so quick to learn😩
Thanks!
Hi Filipe, I want to use your custom picker view on an iOS app I designed. I tried to build your app (Swift 3.2, Xcode 9.1) and there was a Swift Compiler Error saying No Such Module 'PickerView' in ExamplePickerViewController.swift
Sorry, I'm a bit new to iOS development and I feel like I'm not doing something right. Do you know what the problem is?
Some people reach me out reporting about some properties which aren't working when PickerView
is implemented in an Objective-C project.
The known properties with issues:
scrollingStyle
: When its set to .Infinite
, or rawValue 1
, it causes a crash.selectionStyle
: Not working.currentSelectedRow
: Usually it sets a initial selected value to PickerView
but its not appearing as a public property when exposed to Objective-C (even if it is declared as public
in PickerView
).Unfortunately I can't fix this right now, so I'm opening this issue as a [help-wanted]
.
If you can help, please interact here and/or submit a pull request.
Thanks.
I would like to animate highlighting in styleForLabel, so i've overrides this method like this:
if highlighted { UIView.animate(withDuration: 0.5, animations: { label.transform = CGAffineTransform(scaleX: 1, y: 1) }) } else { UIView.animate(withDuration: 0.5, animations: { label.transform = CGAffineTransform(scaleX: 1/2.5, y: 1/2.5) }) }
But this gives me negative effect - it tries to animate labels before the view appears...
So i decided to give my VC an extra property - var beginAnimating = false, and set this to true in viewDidApear. Unfortunately this is not working as I expect =(
Please give me some advices with this issue. Thanks!
Small fix in documentation :
"And the title for each row:
func pickerView(pickerView: PickerView, titleForRow row: Int, index: Int) -> String {
let item = itemsThatYouWantToPresent[row]
return item.text
} "
But we need to use
let item = itemsThatYouWantToPresent[index], not row. It is correct in Example project but not in documentation.
When moving the app to background before the scrolling animation is finished, the system was somewhat firing the orientation changed notification causing a wrong behavior.
Is there a way to refresh number of rows?
Selected values don't line up. Not sure if it is the PickerView or Apple, but here it is, none-the-less.
When I click on the number 9 in the first picker it does this.
If i scroll all pickers to the top (0) then back to the correct value, then it looks correct.
Thereafter it seems to work correctly.
Figure out a better way to highlight customView avoiding to call it when it is nil.
After updating my project to the 0.4.0 version I get the following errors after cleaning build folder and building:
header "PickerView-Swift.h" not found. This file name is not referenced in my project. Also indicates: Could not build Objective-C module 'PickerView'. Which seems to be related to the header file not found. Note that my project is Swift 4.2 not Objc, except for one pod which is objc.
Showing All Messages
Pods/PickerView/Pod/Classes/PickerView.swift:397:76: 'orientationDidChangeNotification' has been renamed to 'NSNotification.Name.UIDeviceOrientationDidChange'
Pods/PickerView/Pod/Classes/PickerView.swift:399:76: 'orientationDidChangeNotification' has been renamed to 'NSNotification.Name.UIDeviceOrientationDidChange'
Xcode Version 10.0 (10A254a).
pod version 1.5.3
Update all pods
Analyzing dependencies
Downloading dependencies
Installing AMPopTip 3.5.0 (was 3.4.0 and source changed to https://github.com/CocoaPods/Specs.git
from https://github.com/cocoapods/specs.git
)
Using CSV.swift (2.2.1)
Installing DeviceGuru 5.0.0 (was 4.0.4 and source changed to https://github.com/CocoaPods/Specs.git
from https://github.com/cocoapods/specs.git
)
Installing Google-Mobile-Ads-SDK 7.35.1 (was 7.33.1 and source changed to https://github.com/CocoaPods/Specs.git
from https://github.com/cocoapods/specs.git
)
Using ObjcExceptionBridging (1.0.1)
Installing PickerView 0.4.0 (was 0.3.4 and source changed to https://github.com/CocoaPods/Specs.git
from https://github.com/cocoapods/specs.git
)
Using SVProgressHUD (2.2.5)
Using SwiftyStoreKit (0.13.3)
Using TPInAppReceipt (1.2.1)
Using XCGLogger (6.1.0)
Generating Pods project
Integrating client projects
Sending stats
Pod installation complete! There are 9 dependencies from the Podfile and 10 total pods installed.
Whenever I update the list of values I want in the PickerView I have to scroll the current value out of view before they update.
I'm changing the PresentationType to updater the list, is this correct or am I missing something?
Noticed that didSelect calls when I take device in hand (no touches) and put it back.
I'm using with iOS 11 and Xcode 9 and when reloadPickerView()
seems to be called my pickerView
starts to act strange. The selection is off center from the overlay I have on with the standard style and my conditions for highlighted
aren't met. Everything seems to get shifted up in position also.
Hi,
thank you so much for this, it's really helpful!
I noticed that the default selected row is not the middle one.
I think the problem is in this code:
Int(ceil(Float(numberOfRowsByDataSource) / 2.0))
Since the row is an index, you have to subtract 1 to numberOfRowsByDataSource, to get the middle one.
For example if we have 5 items, ceil(2.5) is 3, but the middle item index is actually 2.
It would be great to have a public function (or delegate function) that lets you set the first selected item.
Thanks
Can I custom pickerView from nib.
thank you.
Any restrictions in using this within swift 3.0 project?
In the PickerView.swift, I am in an endless loop here, which locks up my app. I'm returning 0 for the pickerViewNumberOfRows delegate, because the user has not yet entered any data. I set the delegate and datasource in viewDidLoad().
`fileprivate func selectedNearbyToMiddleRow(_ row: Int) {
currentSelectedRow = row
tableView.reloadData()
repeat {
// This line adjust the contentInset to UIEdgeInsetZero because when the PickerView are inside of a UIViewController
// presented by a UINavigation controller, the tableView contentInset is affected.
tableView.contentInset = UIEdgeInsets.zero
let indexOfSelectedRow = visibleIndexOfSelectedRow()
tableView.setContentOffset(CGPoint(x: 0.0, y: CGFloat(indexOfSelectedRow) * rowHeight), animated: false)
delegate?.pickerView?(self, didSelectRow: currentSelectedRow, index: currentSelectedIndex)
} while !(numberOfRowsByDataSource > 0 && tableView.numberOfRows(inSection: 0) > 0)
}`
Hi, would you consider adding support for row contents to be a UIView instead of a text label? Thank you for writing PickerView.
Please add a search in piker
Thx!
I'm trying to use this library in SwiftUI but there seems to be an issue. When I present the picker, nothing is shown. I set breakpoint and cellForRowAtIndexPath
is never called.
I searched online and another person is having the same exact issue: https://stackoverflow.com/questions/57297895/swiftui-uitableview-cellforrowatindexpath-never-called-in-uiviewrepresentable
Here is the code in StackOverflow that is very similar to mine that doesn't work:
struct FruitPicker: UIViewRepresentable {
@Binding var fruits: [Fruit]
@Binding var selectedFruit: Fruit
class Coordinator: NSObject, PickerViewDelegate, PickerViewDataSource {
@Binding var fruits: [Fruit]
@Binding var selectedFruit: Fruit
init(fruits: Binding<[Fruit]>, selectedFruit: Binding<Fruit>) {
self._fruits = fruits
self._selectedFruit = selectedFruit
}
func pickerViewNumberOfRows(_ pickerView: PickerView) -> Int {
return self.fruits.count
}
func pickerViewHeightForRows(_ pickerView: PickerView) -> CGFloat {
return 50
}
func pickerView(_ pickerView: PickerView, titleForRow row: Int) -> String {
return self.fruits[row].name
}
func pickerView(_ pickerView: PickerView, didSelectRow row: Int) {
self.selectedFruit = self.fruits[row]
}
}
func makeCoordinator() -> FruitPicker.Coordinator {
return Coordinator(fruits: self.$fruits, selectedFruit: self.$selectedFruit)
}
func makeUIView(context: UIViewRepresentableContext<FruitPicker>) -> PickerView {
let pickerView = PickerView()
pickerView.delegate = context.coordinator
pickerView.dataSource = context.coordinator
return pickerView
}
func updateUIView(_ pickerView: PickerView, context: UIViewRepresentableContext<FruitPicker>) {
}
}
Could you please help out with this?
Hi,
is there any way to decrease scroll speed ?
Can you please help create 2.3 version ?
On iOS 11, an infinite list does not show the selected item anymore, and pressing on items does a really long scroll to the item.
This happens even on the example project included.
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.