yeahdongcn / RSBarcodes

1D and 2D barcodes scanner and generators for iOS7 with delightful controls.
MIT License
383 stars 59 forks source link

Focus yellow line #34

Closed jlanders closed 8 years ago

jlanders commented 8 years ago

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

yeahdongcn commented 8 years ago
  1. If you don't want the view takes full screen, you can have one container view controller and embedded the scanner view controller into it.
  2. 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;
               }
           }
jlanders commented 8 years ago

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!!

yeahdongcn commented 8 years ago

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.

jlanders commented 8 years ago

img_0003 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?

jrlanders commented 8 years ago

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.

yeahdongcn commented 8 years ago

OK, I will find time to do it today.

yeahdongcn commented 8 years ago

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'

jlanders commented 8 years ago

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.

yeahdongcn commented 8 years ago

You have to pod install again. I updated something on 0.1.7.

jrlanders commented 8 years ago

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

jlanders commented 8 years ago

yeahdongcn Worked perfectly now. Thank you

yeahdongcn commented 8 years ago

Great!