ZXingWidgetController shows a blank screen when loaded - objective-c

I am using Xcode 4.1, on iOS Simulator 4.3
I have imported the ZXing library into my project as per the instructions in their README.
When I try to load the controller all I see is a white screen with a Cancel button at the bottom. I know the simulator can't take photos but the controller is then supposed to let you choose an image to decode from the photo library. Has anyone had this issue or has any ideas on what is causing it?
ZXingWidgetController *widController = [[ZXingWidgetController alloc] initWithDelegate:self showCancel:YES OneDMode:NO];
QRCodeReader* qrcodeReader = [[QRCodeReader alloc] init];
NSSet *readers = [[NSSet alloc ] initWithObjects:qrcodeReader,nil];
[qrcodeReader release];
widController.readers = readers;
[readers release];
[self presentModalViewController:widController animated:YES];
[widController release];
EDIT: Forgot to mention, there are pictures on the simulator that I loaded already.

but the controller is then supposed to let you choose an image to
decode from the photo library
Where did you see this? It's not in the README or the code.
The widget doesn't provide an image picker backup. The old Barcodes app (found in cpp/iphone/legacy/Barcodes_original) did but the current Barcodes app doesn't. If you need this, you'll have to implement it yourself. The old Barcodes app might be useful as guide, to some extent.

Related

iOS 8.2 upgrade not show image in UIImageView, but only in app loaded through iTunes or TestFlight not Xcode

As weird as it sounds...
App loaded through test flight or iTunes does not show image on the screen, but it does when it is loaded through Xcode. I believe the UIImageView is there, and the UIImage is loaded.
App loaded through the Xcode works.
If the device is connected to the Xcode and debugging, device connected with USB cable. App works despite the load method...
Core data seems to works in all cases.
Any idea, somebody has seen something similar. I am quite lost.
Also if you have any tip on how to debug this on the device I will appreciate it.
The few code I think it is involve.
I am loading the UIImage from disk using
UIImage * previewImage = [UIImage imageWithContentsOfFile:path];
The image is located in Documents Directory fileName is the input
NSURL *documentsFolderURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
NSString *documentsFolderPath = [documentsFolderURL path];
if (![_documentsDirectory isEqualToString:documentsFolderPath]) [self generateLocaFolderPath];
NSString *returnedPath = [_documentsDirectory stringByAppendingPathComponent:fileName];
return returnedPath;
and setting the image in the imageView with
previewView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frameImageThumbnail.size.width, frameImageThumbnail.size.height)];
[previewView setImage:previewImage];
Everything else seems to work well...
My first question!!! Thanks for reading!
_ edit _
I had the strong believe now that the problem is not in the UIImage, I have use the same methods in other parts of the app and it is working fine.
But now I believe the problem is in the animation I perform to the UIView that contains the UIImageView.
[_view setFrame:frameImageThumbnail];
[_view setClipsToBounds:YES];
[_view setAutoresizesSubviews:YES];
[_image setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[_view addSubview:_image];
[UIView animateWithDuration:0.4
delay:0.1
options:UIViewAnimationOptionCurveEaseInOut
animations:^(void){
CGRect destination1Frame = _view.frame;
//... some complicated calculations with the rect ...
[_view setFrame:destination1Frame];
[UIView transitionFromView:_customView toView:_view duration:0 options: UIViewAnimationOptionShowHideTransitionViews completion:^(BOOL finisehdCompletion){
//stop showing video in _customView
}];
}];
I am using NSAutolayout in the storyboard. Though my application only allows one landscape orientation. No idea if all this meshing up with the frames it is making.
dizzy to the poor auto layout guy...
Make sure you have / your image is set in Copy Bundle Resources. You can check if your image path is valid also. But I think the image is not set to copy at Build Phases.
I had the same problem.. Haven't find a correct solution.
But I deleted the image(check if it's deleted in ur Bundle resources), then put the image again, with ANOTHER name.
It worked for me. It's a temporary solution, idk if it's an apple bug or what.
Ok After more than 20 ipa files build and installed in my devices. In all this process to get rid of the problem I removed the _view from the storyboard, and initiallize the view programmatically. I remember that _view was originally set to (weak, nonatomic) property because was made with the storyboard, this super nice ctrl+.
That was I change I made, weak to Strong, and works now.
I don't know why it didn't work only when the program was install through iTunes with the ipa file or through the test flight app. That is still a mystery to me.

Camera Rotation and OverlayView in iOS8

I am experiencing an issue when using the iPad Camera in iOS 8. I've seen some older questions and a thread on the Apple Developer Forums from during the beta but still haven't find a solution.
There seems to be two parts to this issue.
1) The camera itself rotates when the device orientation rotates, eg the world is on its side
2) When opening the camera in Landscape, the overlay does not appear. When opened in Portrait it is fine.
It is an app using iOS7 as the Base SDK, problem only occurs when running the app on a device that has been upgraded to iOS8. The app is not using storyboards, it is using nibs.
I'm hoping to push out a fix for this with Xcode 5.1.1 before moving onto the iOS8 specific fixes and using it as a Base SDK in the next version.
Here is my code to bring up the camera:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == YES) {
// Create Camera
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.showsCameraControls = NO;
// Set up custom controls view
[[NSBundle mainBundle] loadNibNamed:#"OverlayView" owner:self options:nil];
self.overlayView.frame = imagePicker.cameraOverlayView.frame;
imagePicker.cameraOverlayView = self.overlayView;
self.overlayView = nil;
// Show Camera
[self presentViewController:imagePicker animated:NO completion:nil];
[imagePicker release];
}
I have also tried
And the Layout of the Toolbar (sitting at the bottom) of the OverlayView:
If I change that to sit "at the top" it appears in both portrait and landscape! So it must have to do with the view/window/something size, though it's strange how its behaviour would change when the layout has stayed the same.
I have tried it with both showsCameraControls = YES and hashing out the OverlayView block, and problem #1 persists so it's not to do with the overlay at app.
I'm hoping someone has found an answer to this, it seems like quite a common problem.
Please let me know if you need any further details.
Edit 1: Fixed the Overlay (Issue #2)
It wasn't applying the orientation to the OverlayView, fixed it like this:
// Grab the window frame and adjust it for orientation - from http://stackoverflow.com/a/15707997/520902
UIView *rootView = [[[UIApplication sharedApplication] keyWindow]
rootViewController].view;
CGRect originalFrame = [[UIScreen mainScreen] bounds];
CGRect screenFrame = [rootView convertRect:originalFrame fromView:nil];
...
self.overlayView.frame = imagePicker.cameraOverlayView.frame;
I suspect that it's related to the camera not realising it's orientated too, will keep searching for a fix for Problem #1.
Edit 2: Update on Issue #1
Looks like the camera rotating might be an Apple issue. On iOS8 if you open up the Contacts app, edit a contact and choose 'Take Photo', the exact same issue occurs - in a default Apple app!
I still can't find a fix so I am just destroying and recreating the imagePicker on each orientation change for now, it's ugly but will suffice until Apple release a fix or a better solution pops up.
Apple fixed this problem in iOS 8.1.

how can i show the pdf hyper link data in popover in iPad apps?

i have worked pdf file reader in iPad apps using QLPreviewcontroller but i need to show the inside of pdf hyper link show on popover in iPad any one can help out.
documentPath = [[NSBundle mainBundle] pathForResource:#"my_file" ofType:#"pdf"];
fileURL = [NSURL fileURLWithPath:documentPath];
//fileURL = [NSURL URLWithString:kStringURLUIDocumentInteractionControllerPDF];
}
//creating the object of the QLPreviewController
QLPreviewController *previewController = [[QLPreviewController alloc] init];
//settnig the datasource property to self
previewController.dataSource = self;
//pusing the QLPreviewController to the navigation stack
[[self navigationController] pushViewController:previewController animated:YES];
//remove the right bar print button
[previewController.navigationItem setRightBarButtonItem:nil];
[previewController release];
What you are asking is not impossible, but is extremely complicated and likely will take thousands of lines of code. Quartz has all the functions you'll need to do what your asking, but it will be a major undertaking into poorly documented structures.
This would be much more possible to accomplish using an external library. I've done it before with PSPDFKit as well as Foxit Embedded SDK, but neither is cheap. If your code is GPL licensed, you could consider MuPDF, but it's probably not helpful for commercial software.

Need to post to facebook and twitter from an ios app

I've been doing some research on how to post to fb and to twitter... I know there is a library called Sharekit and I also know I can post using the new iOS6 feature SLComposeViewController... I just need to post a text, that's all... It's not necessary that the user can edit the message...
I need some advice, what would you use?
If you're ok supporting only iOS6, SLComposeViewController is probably easiest. On the Facebook side, you lose nice little features offered via the Facebook SDK for iOS (e.g., the ability to have the Facebook post bear some indication that it came from your app, the graceful inclusion of both images and URLs, etc.).
Bottom line, if you're ok with iOS6-only and you want to keep it simple, SLComposeViewController is probably easiest and can do both Twitter and Facebook. If you want to make the most of Facebook or if you have to support iOS 5, you really have to pursue the Facebook SDK, but it takes a little more code. On the Twitter side, if you need to support iOS 5, then you need to use TWTweetComposeViewController.
Try this one:
- (IBAction)share:(id)sender
{
NSString *text = #"Your message";
UIImage *image = [UIImage imageNamed:#"yourimage.png"];
NSArray *items = [NSArray arrayWithObjects:text,image , nil];
UIActivityViewController *avc = [[avcClass alloc] initWithActivityItems:items applicationActivities:nil];
avc.excludedActivityTypes = #[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll, UIActivityTypeMessage, UIActivityTypeMail];
[self presentViewController:avc animated:YES completion:nil];
}
This should work for you. Just set the NSString and if you want an image.
No frameworks needed!

My UITabBar doesn't show up

Okay guys, maybe you can help me out with this one. I'm about ready to pull my hair out.
Recently I decided to upgrade my app and make it look better, and with that I wanted to move it into full support for iPad platforms as well. For a while everything worked great. Just press copy MainWindow.xib for iPad, add the views that I used on the iPhone configurations, and everything should be great, but that didn't work too well. Take a look:
Here is the iPhone screenshot:
Here is the iPad screenshot:
Where's the tab bar? I don't understand! I added the initial view when I was first putting it together, but when I linked all of the IBOutlets to the proper pieces, the tab bar no longer shows up.
Screenshot of IB:
Tab Bar properties:
Tint: A bluish color
Image Tint: A goldish color
Mode: Scale to fill
Tag: 0
User Interaction Enabled: (Checked)
Multiple Touch: (Unchecked)
Alpha: 1
Opaque: (Checked)
Hidden (Unchecked)
Clears Graphic Context: (Checked)
Clip Subviews: (Unchecked)
Autoresize Subviews: (Checked)
Stretching: (x,y,w,h):(0,0,1,1)
The viewController.h file is a delegate for UITabBar, UITextField, and UITextView
ViewDidLoad (bar is the IBOutlet for the tab bar):
- (void)viewDidLoad
{
[super viewDidLoad];
[self playMovieIntro];
NSURL *url = [NSURL URLWithString:#"http://www.faithlifefellowship.us/Audio/Sermons/NewSermonBanner.png"];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
if(!image == NULL)
{
NewSermonBanner.image = image;
}
series = [[Series alloc] init];
SeriesName = #"";
NSRange range = [[[UIDevice currentDevice] name] rangeOfString:#"iPad"];
int i = 0;
if(range.location != NSNotFound)
i = 1;
bar.selectedItem = hometab;
//set delegates
[bar setDelegate:self];
[personalName setDelegate:self];
[personalEmail setDelegate:self];
[content setDelegate:self];
[prContent setDelegate:self];
[prName setDelegate:self];
[prEmail setDelegate:self];
}
I'm stumped. If you have any ideas or need any more information, let me know.
Thanks!
I'm going to give you a few things I'm getting in order to fix this. It will be tons easier if you could upload the source code for me/us to download and be able to pinpoint the problem.
Sometimes (I can't remember exactly when) I've had my navigation bar not show up because it was missing a connection.
Make sure you are not hiding the tab bar anywhere in code, though it doesn't seem to be the case since it shows up on iPhone.
Otherwise I'm gonna take a guess and say it's something in the NIB. Here are some things you can try:
Check all your connections to outlets
Make sure your objects in the NIB are of the correct class
Verify that the tab bar's "hidden" property is not check in Interface Builder
Compare and verify all the structure of the NIB file between iPhone and iPad
These are just some ideas :) again if you can post the code it would be fantastic.
Let us know how it goes,
Felipe
I had this problem with a app that support both iPhone and iPad. Make sure 'is initial view controller' is checked for the UITabBarController when you examine the view controller using the object inspector. When you do this, xcode will display a 'inbound' arrow on the left side of the view controller if you're using storyboards.