I'm trying to use the ZBar SDK to create an embedded QR Code reader just like shown in the example here: https://github.com/twotoasters/zbar (the Embeded Reader example)
The only difference is that I'm using it in storyboards. I tried copying the code into my application and everything seems to be fine, until I actually try to use it.
I'm working on a simulator, so the ZBarCameraSimulator is initializing and showing it's text, but when I try the "two finger click" (checked the Multitouch Option in the Subview attributes) it seems to ignore the action.
I guess there is a delegate or a handler missing, which was not required in with XIBs but is necessary within the Storyboards.
Anybody got any clues? Would be thankful.
Ok, looks like I found the solution,
I was assuaging the readerView to a (weak, nonatomic) IBOutlet property, while the XIB project used "retain" option. I changed the option to strong (as what I understand from ARC, retain shouldn't be used with it) and it started working.
I am also using this with storyboard and have had no trouble having the simulator recognise the two finger click. I do this by pressing Option+Mouse and holding it for a second.
I do however have follow on issues where the scanned image does not seem to be processed, but I think that my be due to a delegate issue.
Related
I have an NSOutlineView and a stack of objects, you can imagine it is a tree of files.
So I tried to extend the NSTextFieldCell class to parse the name of the current item and render an icon for it. But I am still stuck in the icon part. I simply can't get a standard-hardcoded-image to work!
I tried many tutorials, the only one I got to work is a class called PXSourceList, but it was designed for OSX 10.7+. Also the majority of these tutorials use AppDelegate with the NSOutlineViewDataSource protocol and I also want the code to be managed elsewhere, not in the APPDelegate class.
Can someone give-me some directions on the first steps? I think a bit of enlightenment on how the general logic surrounding the icon thing would be enough. I appreciate!
I use XCode 4.2 for Snow Leopard. The project I'm on is supposed to work in OSX 10.6+, so I can't use the new Lion approach of cells using NSViews.
You can get the file icon from its path as follows;
NSImage *iconImage1 = [[NSWorkspace sharedWorkspace] iconForFile:filepath];
You need an image cell to display the icon image.
I am trying to utilize UIWebView functionality, specifically I want to do something like this: Open links in Safari instead of UIWebVIew?
But I am having an issue when I try and add the UIWebViewDelegate to my AppDelegate interface.
Anyone know what the issue is? Note this is Mac OS not iOS.
Add:
#import <UIKit/UIKit.h>
Anyone know what the issue is? Note this is Mac OS not iOS.
That's the issue right there.
There is no UIWebView or UIWebViewDelegate on MacOS X. UI is the prefix for UIKit, which is the iOS equivalent of AppKit. When you see a class whose name begins with UI, you know immediately that you're looking at iOS code.
The class you're probably looking for is WebView. WebView actually uses five separate delegates, so you may need to implement as many as five different protocols: WebUIDelegate, WebDownload, WebFrameLoadDelegate, WebPolicyDelegate, and WebResourceLoadDelegate. (In reality, I don't think you need to do quite that much work. For example, you may not need to implement your own access policy.)
UIWebView is iOS only. You cannot use a UIWebViewDelegate for Mac OSX. If you look at your own code, you are using a WebView, not a UIWebView.
You'll want to look at the WebView class docs
My app is using a 2nd UIWindow to show a special screen if iOS wants to take a screenshot of the app.
By accident I used [UIWindow makeKeyWindow:] on my main window if I wanted to remove the 2nd window again. This really should be makeKeyAndVisible: instead but I'm wondering why it worked at all.
I mean: most of the time (99%), my 2nd window was removed as expected and my main window became visible.
I'm asking because I'm wondering if I have really found the problem or if there might still be something else?
Or could it be that the method was incorrectly bound in (previous) MonoTouch versions?
Each method maps to the selector of the same name makeKeyAndVisible and makeKeyWindow.
Or could it be that the method was incorrectly bound in (previous) MonoTouch versions?
GIT history shows (me ;-) that both never changed since they were first added (more than two years ago).
Documentation about the former states:
You can also hide and reveal a window using the inherited hidden property of UIView.
Maybe this happens in your code (or even within the iOS code).
I am trying to make a simple app from a tutorial that does not have a viewController at all. All the code is in the AppDelegate. I am on xcode 4.2 and I am getting this error:
Applications are expected to have a root view controller at the end of application launch
I'm not sure how to deal with this. There are some blogs out there with fixes but none of them are working for me and I really would like to understand what is going on here. And, how to fix it.
I do have a view that contains some buttons and labels. But I have no "ViewController". The files contained in my project are: AppDelegate.h, AppDelegate.m, and Window.xib only. There is no ViewController.h, ViewController.m
** edit **
I ended up making the app from a 'view based application' instead and just moving all the logic from the app delegate to the view controller. So, I didn't really solve the problem per se. The app works now though. Thanks for the help
It's not possible to have an iOS app that doesn't have a view controller. You can always create a trivial view controller, i.e.,
[[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds].rootViewController =
[[[UIViewController alloc] init] autorelease];
It sounds like you're looking at an old tutorial. UIWindow got a rooViewController property in iOS4. I believe it became required in iOS5 to help keep controller hierarchies and view hierarchies in sync with the addition of custom container controllers (and to fix a corner case where replacing the "root controller" of a UIWindow could stop orientation changes from propagating). There was a WWDC presentation in 2011 that explained this in some detail. I think it was Session 102, Implementing UIViewController Containment.
At then end of the day, there's no good reason not to have a root view controller. Apple wants to be able to assume it's there in their APIs going forward. If the tutorial you're looking at doesn't account for that, it's broken.
While I agree that there may be workarounds, another question to address is: why do you want an app without a view? Even if it's designed to run in the background and present no visual interface, at least make a simple view showing the application name and version, a largeish icon and perhaps a status. This kind of idle screen uses very little system resources, especially when the app is backgrounded, but improves the overall experience of the app.
If you set your deployment target to 4.3 and run on the iPhone 4.3 simulator, you won't get the warning.
To install the iOS 4.3 simulator, go to Xcode > Preferences > Downloads.
My iPad app was working fine until I opened up IB and started editing the interface. Now, my application:didFinishLaunchingWithOptions isn't getting called. I understand it's an optional function and it gets skipped if it doesn't exist, but in my case it does. What are some reasons that application:didFinishLaunchingWithOptions method could get skipped?
I should note that I'm building with the iPhone OS 3.2 SDK.
Thanks in advance for your help!
UPDATE: I fixed it, please see my answer below
Are you sure that class has been set as the application delegate of the app?
(source: xanga.com)
And also make sure the "File's Owner"'s delegate has been linked to "App Delegate".
(source: xanga.com)
Well it turns out, for an unknown reason, I had a "view" view object as a child of my RootViewController in IB that didn't serve any purpose except to hold my a TableView view object and a DatePicker view object. I thought it was harmless, but when I removed it in IB and programmatically added the TableView object and and DatePicker object, suddenly this problem went away. If anyone has any ideas why this is, I'd would love to understand it.
Thanks, everyone!