marxon13 / m13checkbox Goto Github PK
View Code? Open in Web Editor NEWA customizeable checkbox for iOS
License: MIT License
A customizeable checkbox for iOS
License: MIT License
Hello,
Found a small bug on line 312 in M13Checkbox.swift:
manager.resetLayersForState(checkState)
should be
manager.resetLayersForState(newState)
right now its just setting it to the current state so it never changes.
Best,
Mike
When I try to install M13Checkbox by cocoa pods, prompts an error:
$ pod install
Analyzing dependencies
[!] The platform of the target Pods
(iOS 6.0) is not compatible with M13Checkbox (1.1.0)
which has a minimum requirement of iOS 7.0.
Am I going crazy or does programatically setting the checkState
in iOS 7 not work as expected?
I've tried both:
[self.readTermsCheckbox setCheckState:M13CheckboxStateChecked];
and:
self.readTermsCheckbox.checkState = M13CheckboxStateChecked;
Both ways work fine on iOS 8 and iOS 9 but on iOS 7, I see the code gets called and in debugging I can see the value gets set correctly but the view is just not updating to show the new state. What am I missing?
I have also tried calling [self.readTermsCheckbox setNeedsDisplay];
but still no joy.
if I use other animation style like bounds or stroke, this not happen.
Hi, is it possible in any way to anchor the check box to the top of the frame (in the case of multiline label)?
Build fails in this line:
let longPressGesture = M13CheckboxGestureRecognizer(target: self, action: #selector(M13Checkbox.handleLongPress(_:)))
with Expected instruction in list of expressions
and Expected ',' separator
and Missing argument for parameter 'action' in call
.
when i run app error
Use of unresolved identifier 'M13CheckboxStrokeManager'
why ?
I'm trying to follow the instructions for running the Demo app, but I'm running into an issue:
# Since I'm using Xcode 8
$ gem install cocoapods --pre
...
Successfully installed cocoapods-1.1.0.rc.2
...
$ pod install
Analyzing dependencies
Downloading dependencies
Using Color-Picker-for-iOS (2.0.2)
Using PBDCarouselCollectionViewLayout (1.1.0)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 2 dependencies from the Podfile and 2 total pods installed.
[!] The `M13Checkbox Demo [Debug]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-M13Checkbox Demo/Pods-M13Checkbox Demo.debug.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
[!] The `M13Checkbox Demo [Release]` target overrides the `ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES` build setting defined in `Pods/Target Support Files/Pods-M13Checkbox Demo/Pods-M13Checkbox Demo.release.xcconfig'. This can lead to problems with the CocoaPods installation
- Use the `$(inherited)` flag, or
- Remove the build settings from the target.
Usually you need to open the .xcworkspace
file, so I tried that first, but it was missing projects, so then I tried opening the .xcodeproj
as instructed in the README.
When I select the "M13Checkbox Demo" scheme and run, it displays the error:
No such module 'Color_Picker_for_iOS'
Did I do something wrong, or is this a bug?
Is there a fork that has been updated to switch the deprecated method calls for iOS7 to the new methods?
When the M13Checkbox is added to a view that has a UITapGestureRecognizer added to it, the M13Checkbox does not receive tap events. Applying the following diff to this project will demonstrate the problem easily:
--- a/M13Checkbox/ViewController.m
+++ b/M13Checkbox/ViewController.m
@@ -114,13 +114,6 @@
customFrame.titleLabel.numberOfLines = 0;
customFrame.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
[self.view addSubview:customFrame];
-
- UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleRecognizerTap)];
- [self.view addGestureRecognizer:recognizer];
-}
-
-- (void)handleRecognizerTap {
- NSLog(@"Tapped");
}
- (void)didReceiveMemoryWarning
This does not appear to be the standard behavior of UIControls. For example, a UIButton added to the same view is able to receive tap events with no problem. The same is true of UITextFields and other UIControls.
setEnabled doesn't check if the new enabled state is the same as the old one. As a result, setting enabled = false multiple times causes the text to lighten until it's white (and likely invisible).
hi . it's very nice .
but When I run the program,Black window and something does not come up and log : ```
M13Checkbox Demo[20038:913393] unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: <UIClassicWindow: 0x7ff1bc803d30; frame = (0 0; 414 736); userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x7ff1bad12020>; layer = <UIWindowLayer: 0x7ff1bc8046d0>>
2016-04-15 07:14:58.342 M13Checkbox Demo[20038:913393] unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: <UIClassicWindow: 0x7ff1bc803d30; frame = (0 0; 414 736); userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x7ff1bad12020>; layer = <UIWindowLayer: 0x7ff1bc8046d0>>
2016-04-15 07:14:58.870 M13Checkbox Demo[20038:913393] unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: <UIClassicWindow: 0x7ff1bc803d30; frame = (0 0; 414 736); userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x7ff1bad12020>; layer = <UIWindowLayer: 0x7ff1bc8046d0>>
The checkbox state seems to be controlled by M13checkbox
how can I control it by my own code?
I tried setState but still no luck
Hi guys. Love the framework and use it extensively in my apps.
Just wondering about support for Swift 3, since I'm hoping to release an app optimized for iOS10 on launch day.
If there's no plans underway it's something I'd be willing to help out with.
I add the following method.
What do you think ?
// M13Checkbox.m
(void)autoSizeToFit {
_titleLabel.numberOfLines = 0;
_titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
CGSize margin = CGSizeMake(5.0, 5.0);
CGRect labelrect = [_titleLabel.text
boundingRectWithSize:CGSizeMake(_titleLabel.bounds.size.width - margin.width * 2,
CGFLOAT_MAX)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{
NSFontAttributeName : _titleLabel.font
}
context:nil];
self.frame = CGRectMake(
self.frame.origin.x, self.frame.origin.y,
labelrect.size.width + ([self heightForCheckbox] * kCheckBoxSpacing) +
((kBoxSize + kCheckHorizontalExtention) * [self heightForCheckbox]),
labelrect.size.height);
[self layoutSubviews];
}
I want to expand only hitTest(range of touchable), but not want to expand checkbox itself.
[!] The platform of the target XYZ
(iOS 6.0) is not compatible with M13Checkbox (1.1.0)
which has a minimum requirement of iOS 7.0.
Hi, I'm seeing increased compilation times for this project (version 2.2.4) and it causes to XCode 8 to be really slow. I ran the command mentioned here: http://irace.me/swift-profiling and it gave me this:
17059.2ms /XXX/Pods/M13Checkbox/Sources/M13CheckboxPathPresets.swift:113:43 get {}
16583.8ms /XXX/Pods/M13Checkbox/Sources/M13CheckboxPathPresets.swift:113:43 get {}
10840.5ms /XXX/Pods/M13Checkbox/Sources/M13CheckboxPathPresets.swift:76:55 get {}
10393.4ms /XXX/Pods/M13Checkbox/Sources/M13CheckboxPathPresets.swift:76:55 get {}
The times vary, but they are always really high (min. 6000ms).
Can you look into it? Thanks
I would like to use this library on swift 2.3 with xcode8.
But i could not find way to use.
This looks for only Swift3.
Are there way to use it on Swift 2.3?
I am trying to fix swift branch then,I am trying to use it.
Someone has taken claim to your repo https://github.com/Boris-Em/BEMCheckBox
Hi, thanks for this amazing tool, today I faced 2 issues and my questions to those are:
Many thanks in advance
The UIControlEventValueChanged
action message is sent from the beginTrackingWithTouch:withEvent:
method, but the checkbox's value isn't actually changed in that method. The checkbox's value is changed in the endTrackingWithTouch:withEvent:
method. Should the UIControlEventValueChanged
action message instead be sent from the endTrackingWithTouch:withEvent:
method?
Hello Brandon, I have one question. I need use checkbox with some text. I can use M13CheckboxAlignment. But in this case it strictly bind to side(right or left). Is any way to set something like button contentEdgeInset? I need add some padding from side.
Thanks.
Hi! @Marxon13
Jack
Currently pod trunk push
and pod spec lint
are failing. Working on a fix, there is no clear solution that I can find. I tried overriding the SWIFT_VERSION
config property, but that is not working. As soon as a solution is found, I'll update Cocoapods.
Hi Pals, I am trying to implement your great checkbox, but when checking control it's changing my tint color to blue. How I can fix it. Is there some delegate methods to catch checked/unchecked values like 0 and 1?
I believe it should return uncheckedValue
instead of mixedValue
- (id)value
{
if (self.checkState == M13CheckboxStateUnchecked) {
return mixedValue;
} else if (self.checkState == M13CheckboxStateChecked) {
return checkedValue;
} else {
return mixedValue;
}
}
Hi, your component is great, alghough, I'm getting weird logs that look like:
Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored. Please fix this problem.
Oct 7 13:44:31 HDM Survey[897] <Error>: Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored. Please fix this problem.
2016-10-07 13:44:31.829081 HDM Survey[897:303416] If you want to see the backtrace, please set CG_NUMERICS_SHOW_BACKTRACE environmental variable.
Oct 7 13:44:31 HDM Survey[897] <Error>: If you want to see the backtrace, please set CG_NUMERICS_SHOW_BACKTRACE environmental variable.
2016-10-07 13:44:31.829793 HDM Survey[897:303416] Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored. Please fix this problem.
Oct 7 13:44:31 HDM Survey[897] <Error>: Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored. Please fix this problem.
2016-10-07 13:44:31.834693 HDM Survey[897:303416] If you want to see the backtrace, please set CG_NUMERICS_SHOW_BACKTRACE environmental variable.
Oct 7 13:44:31 HDM Survey[897] <Error>: If you want to see the backtrace, please set CG_NUMERICS_SHOW_BACKTRACE environmental variable.
Adding a symbolic error(CGPostError), got this Backtrace (using bt on lldb):
thread #1: tid = 0x4a138, 0x00000001888ebe0c CoreGraphics`CGPostError, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1
frame #0: 0x00000001888ebe0c CoreGraphics`CGPostError
frame #1: 0x00000001886d001c CoreGraphics`CGFloatValidateWithLog + 80
frame #2: 0x000000018889d0dc CoreGraphics`CGPathAddLineToPoint + 96
frame #3: 0x000000018d202778 UIKit`-[UIBezierPath addLineToPoint:] + 36
* frame #4: 0x0000000100a27bec M13Checkbox`M13CheckboxPathPresets.pathForCheckmark(self=0x0000000170110a10) -> UIBezierPath + 192 at M13CheckboxPathPresets.swift:286
frame #5: 0x0000000100a280a0 M13Checkbox`M13CheckboxPathPresets.pathForUnselectedCheckmark(self=0x0000000170110a10) -> UIBezierPath? + 28 at M13CheckboxPathPresets.swift:356
frame #6: 0x0000000100a279fc M13Checkbox`M13CheckboxPathPresets.pathForUnselectedMark(self=0x0000000170110a10) -> UIBezierPath? + 80 at M13CheckboxPathPresets.swift:349
frame #7: 0x0000000100a27978 M13Checkbox`M13CheckboxPathPresets.path(state=unchecked, self=0x0000000170110a10) -> UIBezierPath? + 96 at M13CheckboxPathPresets.swift:260
frame #8: 0x0000000100a34654 M13Checkbox`M13CheckboxStrokeManager.layoutLayers(self=0x00000001700bd0a0) -> () + 1420 at M13CheckboxStrokeManager.swift:196
frame #9: 0x0000000100a246ec M13Checkbox`M13CheckboxManager.resetLayersForState(state=unchecked, self=0x00000001700bd0a0) -> () + 60 at M13CheckboxManager.swift:88
frame #10: 0x0000000100a34788 M13Checkbox`M13CheckboxStrokeManager.resetLayersForState(state=unchecked, self=0x00000001700bd0a0) -> () + 72 at M13CheckboxStrokeManager.swift:204
frame #11: 0x00000001009f85bc M13Checkbox`M13Checkbox.sharedSetup(self=0x0000000101655920) -> () + 612 at M13Checkbox.swift:250
frame #12: 0x00000001009f82c8 M13Checkbox`M13Checkbox.init(aDecoder=0x00000001018c1a00) -> M13Checkbox? + 760 at M13Checkbox.swift:240
frame #13: 0x00000001009f834c M13Checkbox`@objc M13Checkbox.init(coder : NSCoder) -> M13Checkbox? + 52 at M13Checkbox.swift:0
frame #14: 0x000000018d544b78 UIKit`-[UIClassSwapper initWithCoder:] + 248
frame #15: 0x000000018d69464c UIKit`UINibDecoderDecodeObjectForValue + 672
frame #16: 0x000000018d694394 UIKit`-[UINibDecoder decodeObjectForKey:] + 104
frame #17: 0x000000018d54481c UIKit`-[UIRuntimeConnection initWithCoder:] + 188
frame #18: 0x000000018d69464c UIKit`UINibDecoderDecodeObjectForValue + 672
frame #19: 0x000000018d6947c0 UIKit`UINibDecoderDecodeObjectForValue + 1044
frame #20: 0x000000018d694394 UIKit`-[UINibDecoder decodeObjectForKey:] + 104
frame #21: 0x000000018d543b1c UIKit`-[UINib instantiateWithOwner:options:] + 1212
frame #22: 0x000000018d3a4648 UIKit`-[UIViewController _loadViewFromNibNamed:bundle:] + 372
frame #23: 0x000000018d176868 UIKit`-[UIViewController loadView] + 176
frame #24: 0x000000018d042074 UIKit`-[UIViewController loadViewIfRequired] + 184
frame #25: 0x000000018d0fbfcc UIKit`-[UINavigationController _layoutViewController:] + 72
frame #26: 0x000000018d0fbea4 UIKit`-[UINavigationController _updateScrollViewFromViewController:toViewController:] + 416
frame #27: 0x000000018d0fb1ec UIKit`-[UINavigationController _startTransition:fromViewController:toViewController:] + 140
frame #28: 0x000000018d0fac38 UIKit`-[UINavigationController _startDeferredTransitionIfNeeded:] + 856
frame #29: 0x000000018d0fa7ec UIKit`-[UINavigationController __viewWillLayoutSubviews] + 64
frame #30: 0x000000018d0fa750 UIKit`-[UILayoutContainerView layoutSubviews] + 188
frame #31: 0x000000018d03f54c UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1196
frame #32: 0x000000018a50740c QuartzCore`-[CALayer layoutSublayers] + 148
frame #33: 0x000000018a4fc0e8 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 292
frame #34: 0x000000018a4fbfa8 QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
frame #35: 0x000000018a478c64 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 252
frame #36: 0x000000018a4a00d0 QuartzCore`CA::Transaction::commit() + 512
frame #37: 0x000000018a4a0af0 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 120
frame #38: 0x00000001871ad7dc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
frame #39: 0x00000001871ab40c CoreFoundation`__CFRunLoopDoObservers + 372
frame #40: 0x00000001871ab89c CoreFoundation`__CFRunLoopRun + 1024
frame #41: 0x00000001870da048 CoreFoundation`CFRunLoopRunSpecific + 444
frame #42: 0x0000000188b5d198 GraphicsServices`GSEventRunModal + 180
frame #43: 0x000000018d0ad628 UIKit`-[UIApplication _run] + 684
frame #44: 0x000000018d0a8360 UIKit`UIApplicationMain + 208
frame #45: 0x000000010017a920 HDM Survey`main + 140 at AppDelegate.swift:6
frame #46: 0x00000001860bc5b8 libdyld.dylib`start + 4
Thanks so much for this awesome control.
Would you consider adding it to CocoaPods. It'd make it much easier to pull in and update as a project dependency. See http://cocoapods.org for more details.
Hello!
Is there any way to deactivate the rest of checkboxes when one is tapped?
Thanks.
Hello Brandon,
I want to create a checkbox from the IB. So I dragged and placed a UIView and set its class as M13Checkbox. And referenced it as an IBOutlet in the view controller.
@property (strong, nonatomic) IBOutlet M13Checkbox *checkBox1;
I initialized it like this in the viewDidLoad method,
self.checkBox1 = [[M13Checkbox alloc] initWithTitle:@"Now to 3 Months"];
self.checkBox1.radius = 5.0;
The checkbox appears but without the title and also its not the radius one I needed.
Any idea what I'm missing here and how to correct it?
Thank you :)
Using XCode 4.6.1 interface builder
In the debugger I have verified that M13Checkbox's -initWithFrame: method is called and executes correctly. Using DCIntrospect I have found that when created this way the M13Checkbox instance doesn't contain the CheckView and UILabel subviews
Here's the (truncated) output of DCIntrospect:
2013-04-08 19:00:13.081 XXXXXXX[25443:c07] DCIntrospect: <UIView: 0xe5815f0; frame = (0 20; 320 460); autoresize = RM+BM; layer = <CALayer: 0xe581650>>
| <M13Checkbox: 0x7871820; baseClass = UIControl; frame = (20 57; 16 16); layer = <CALayer: 0x78718f0>>
| <M13Checkbox: 0x786c9a0; baseClass = UIControl; frame = (80 25; 16 16); layer = <CALayer: 0x7868f40>>
| | <CheckView: 0xe575ce0; frame = (0 0; 16 16); userInteractionEnabled = NO; layer = <CALayer: 0xe59bf00>>
| | <UILabel: 0x7d981e0; frame = (-5 2; 5 14); clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x7d9a6e0>>
In that log the first instance of M13Checkbox is the one created in IB. The second instance of M13Checkbox is created entirely in code. That second instance works as expected.
I don't use cocoapods.
Would be good if the demo worked out of the box, or if there were more than one option to fetch dependencies.
I've included M13Checkbox (v 2.1.0) as a pod in an Objective-c project. The pod seems to install correctly, certainly well enough to integrate it in the storyboard.
I just noticed that when I tried to call setCheckState(newState: CheckState, animated: Bool)
on a checkbox in a UIView subclass, the compiler doesn't seem to know anything about the method.
I had a look at the swift bridging header that was generated, and it looks like it's missing a few things. https://gist.github.com/churowa/66f54a984d58f2b8ecdb8f60602f6af5
Just comparing it to the available properties in M13Checkbox.swift, I see right away that it's missing setCheckState
, boxType
, stateChangeAnimation
, and a few others.
Am I correct that it looks odd? I'm not sure what to look at next, basically. I don't know that this is an M13Checkbox issue per se... Maybe it's more to do with Cocoapods or Xcode itself. But does the bridging header look right?
Hi ,
Is there any way i Could use this for single selection radio button in group
Thanks Regards
There is no callback delegate classes for changes in checkbox state. Any idea how to workaround that?
Hi, I installed the framework you with carhage, the only problem is that if the code side everything seems to work, the side storyboard get a "Unknown M13Checkbox class in Interface Builder files" running.
I plugged in bridging header import but still does not work.
do you have any ideas on how to solve it?
Would it be possible to make the titleLabel a multiline one that can have a greater height than the checkbox itself?
Hi !
this is probably a newbie question :(
How can I register a M13Checkbox for actions. F.e. if something got selected and so on ?
I have a configuredcell method for a custom uitableviewcell which initiate a m13checkbox everytime cellForRowAtIndexPath is called.
when I click on the checkbox in any row, the other checkboxes in random row will show a the box with a small line above the top right of the box whenever i scroll the UITableView. It will display like the image attached below
Hey Folks,
since Xcode 8 is available and Swift 2.3 conversion is recommended i have an error within your Framework.
"error: IB Designables: Failed to render and update auto layout status for UIView (iN0-l3-epB): dlopen(M13Checkbox.framework, 1): Symbol not found: __TWPSis16ForwardIndexTypes
Referenced from: M13Checkbox.framework
Expected in: (shortended).../Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Overlays/../../../../../../Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator/libswiftCore.dylib
in M13Checkbox.framework
The whole xib is not renderable in interface builder if a m13checkbox is within a xib file. If i reset the class it runs until i reopen it in interface builder.
I Want to use your framework further on so do you have any suggestion?
greetings
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.