Closed jlanders closed 8 years ago
You can have a certain rect, only the barcode inside this area will be recognized, I can provide you some demo code (should be placed inside the barcodes handler)
NSArray *corners = [machineReadableCodeObject corners];
ScannerView *sv = [self.view viewWithTag:200];
CGRect frame = [sv frameOfCaptureView];
BOOL isAllCornersInside = YES;
for (NSDictionary *corner in corners) {
CGPoint point = CGPointMake([[corner objectForKey:@"X"] floatValue],
[[corner objectForKey:@"Y"] floatValue]);
if (!CGRectContainsPoint(frame, point)) {
isAllCornersInside = NO;
break;
}
}
Hi yeahdongcn, Fairly new to xcode. How do you embed a view inside of a view? Also is that code above objective C or Swift? Looks like C to me. Thank you for replying!!
How do you embed a view inside of a view? https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ImplementingaContainerViewController.html
The code is Objective-C, I think it could be simply converted to swift.
yeahdongcn, I can successfully create the container view and the scan window populates that container as it should. However regardless of how I apply constraints, the container no only takes up most of the screen, but a portion of it is down and to the right moving what looks like off the screen as well. Is there something that is causing an over ride so that constraints will not hold on the container?
As a follow-up thought, The constraints do hold on the container if I fill the contain with any besides the RSCodeReaderViewController class. Once I attach that to the view it blows the screen of the side which makes me wonder of there is a fixed screen size calculated in RSCodeReaderViewController?
Any Thoughts or pointers?
yeahdongcn, Would you be willing to put together a quick example showing RSCodeReaderViewController inside of a container view with the container view sized to about 1/3 of the ipad window size and centered horizontally and vertically? I would greatly appreciate it. I cant seem re resize RSCodeReaderViewController and this is last part of this project. Thank you for your time.
OK, I will find time to do it today.
https://github.com/yeahdongcn/RSBarcodes_Swift/tree/container-view-controller-sample
Please take a look and update your podfile pod 'RSBarcodes_Swift', '~> 0.1.7'
Awesome Example yeahdongcn. Thank you very much. When I run your sample independently it works great. When I try an copy everything you have done into my project I get the same results where the window will not hold he constrains. So strange. I can't figure it out. I will keep trying.
You have to pod install again. I updated something on 0.1.7.
ok will try that
On Wed, Mar 23, 2016 at 8:24 AM, R0CKSTAR notifications@github.com wrote:
You have to pod install again. I updated something on 0.1.7.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/yeahdongcn/RSBarcodes/issues/34#issuecomment-200366579
James Landers
yeahdongcn Worked perfectly now. Thank you
Great!
I have the code working well. One problem I do have is the view on the controller takes up the entire window. There are times when the label I am trying to scan has two or multiple barcodes. How do I make the viewer distinguish between the two. I would think the yellow bar line would help target the scanner, however the yellow line seems random when it shows up.
Any suggestions? Oh, and I am using the swift version. I posted here as it seems to have more activity than the other.
Looking forward to your thoughts or direction.
Thank you