How to disable "shake to undo" in iPhone application written with Phonegap? - iphone

The only thing I've found is that you have to set UIApplicationSupportsShakeToEdit to false in plist file but it doesn't work for me.

I inserted this line:
[UIApplication sharedApplication].applicationSupportsShakeToEdit = NO;
in the webViewDidFinishLoad class, it worked wonders for me.
Go to the MainViewController.m and change webViewDidFinishLoad to look like this:
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
// Black base color for background matches the native apps
theWebView.backgroundColor = [UIColor blackColor];
[UIApplication sharedApplication].applicationSupportsShakeToEdit = NO;
return [super webViewDidFinishLoad:theWebView];
}

Related

ZBar API Embedded Scanner Blur issue

I am using ZBar iPhone SDK in one of my projects (iOS SDK 5.1 ,XCode 4.4.1 and device running iOS 5.5.1). I am using the embedded scanner from the examples provided in the SDk itself.
Now the issue which I am facing is that I successfully scan a bar code and move to another view controller ( using navigation controller). When I come back (pop the second view controller) the scanner i.e the ZBarReaderView doesn't scan the subsequent bar codes , infact the overlay shows a blur image of the scanned barcode and is never able to scan it properly.
This is what all I have implemented . In BarScannerViewController.h I have declared
ZBarReaderView* readerView;
with property
#property (nonatomic , retain) IBOutlet UIImageView* imgvScannedBarCode;
Now this is connected to one of the views in xib.
Finally I use set up the required methods as follows -
- (void)viewDidLoad {
[super viewDidLoad];
// the delegate receives decode results
readerView.readerDelegate = self;
[readerView start];
}
- (void) viewDidAppear: (BOOL) animated {
// run the reader when the view is visible
[activityIndicatorScanning startAnimating];
[readerView start];
}
- (void) viewWillDisappear: (BOOL) animated {
[activityIndicatorScanning stopAnimating];
[readerView stop];
}
With all this set up when I scan any bar code say EAN123 for the first time I get the call back in
- (void) readerView: (ZBarReaderView*) view
didReadSymbols: (ZBarSymbolSet*) syms
fromImage: (UIImage*) img
{
// do something useful with results
ZBarSymbol *symbol = nil;
for(symbol in syms) {
barCodeFound = YES;
break;
}
// EXAMPLE: do something useful with the barcode data
NSLog(#"%#",symbol.data);
}
but on subsequent runs (After I push a view and come back on this screen again) I get blurred view.
Am I missing something here ? Any help/Suggestion/Comments would be helpful.
Here's the code that I use to start (and endlessly restart) the scanner. Interestingly, I note that I never stop the scan, but it works very reliably.
- (void) startScan
{
ZBarReaderViewController *reader = [ZBarReaderViewController new];
reader.readerDelegate = self;
ZBarImageScanner *scanner = reader.scanner;
[scanner setSymbology: ZBAR_I25
config: ZBAR_CFG_ENABLE
to: 0];
// present and release the controller
[self presentViewController:reader animated:YES completion:nil]; // Modal
[reader release];
}
I could solve the Blur issue by reconfiguring the SDK in my project. I followed the embedded scanner example as provided on ZBarSDk. I guess I might have missed some essential settings while configuring it earlier.

ViewController doesn't show until I quit and relaunch app

I have just made my app universal by combining separate iPhone and iPad projects. Everything seems to be working but there is one major bug.
When the iPad app launches it just displays a black screen (presumably the window) and status bar. When I press the home button I suddenly see the SplitViewController as it disappears. When I open the app up again the SplitViewController is displayed.
I can't figure out why the controller only displays after I close and reopen the app. Any ideas?
(I don't have any idea what is causing this so if you need code samples from specific places let me know).
Thanks.
Edit:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Appirater appLaunched:YES];
// Registers this class as the delegate of the audio session.
[[AVAudioSession sharedInstance] setDelegate: self];
// Allow the app sound to continue to play when the screen is locked.
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
justOpened = YES;
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
{deleted}
} else {
[self.window addSubview:self.splitViewController.view];
[self.window makeKeyAndVisible];
CGRect rect = CGRectMake(-2, self.window.frame.size.height-29, self.window.frame.size.width+2, 29);
imgBar = [[UIImageView alloc] initWithFrame:rect];
imgBar.contentMode = UIViewContentModeScaleToFill;
imgBar.image = [UIImage imageNamed:#"wood_btm.png"];
imgBar.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleTopMargin;
self.splitViewController.showsMasterInPortrait = YES;
self.splitViewController.title = #"Exams";
self.splitViewController.splitPosition=280;
}
return YES;
}
Update:
By messing around with the window's background color I discovered that for some reason it was at the top of the view hierarchy. I then made the window's background color clear and I could see the SplitViewController. Strangely I can also interact with it. So essentially I have solved the problem by making the window clear. This is obviously not the ideal solution though so if anyone can think of a cause let me know.
[self.window addSubview:self.splitViewController.view];
[self.window makeKeyAndVisible];
return YES;
should be at the end of -applicationDidFinishLaunching:WithOptions: method.
By messing around with the window's background color I discovered that for some reason it was at the top of the view hierarchy. I then made the window's background color clear and I could see the SplitViewController. Strangely I can also interact with it. So essentially I have solved the problem by making the window clear.

Different behavior of app while testing on device and simulator?

I m working on an app in which i have 5 buttons(having .png images included in resources) m hiding them in viewDidload and showing them after choosing the image from UIImagepickerView.
All is going well in simulator but when i launch the app on device i cant find those buttons.
anyone have any idea of this situation?????
here is the code of my hiding and showing the buttons.
- (void)viewDidLoad {
[super viewDidLoad];
self.count1 = 1;
btnAddPimple.hidden = YES;
btnAddPimple2.hidden = YES;
btnAddPimple3.hidden = YES;
btnAddPimple4.hidden = YES;
btnAddPimple5.hidden = YES;
self.navigationController.navigationBar.hidden=YES;
Here I am showing the buttons after choosing image from Imagepicker.
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
imgToDisplayFromPicker.image = [[info objectForKey:UIImagePickerControllerOriginalImage]retain];
[[picker parentViewController]dismissModalViewControllerAnimated:YES];
[picker release];
btnAddPimple.hidden = NO;
btnAddPimple2.hidden = NO;
btnAddPimple3.hidden = NO;
btnAddPimple4.hidden = NO;
btnAddPimple5.hidden = NO;
for (UIView *subview in [self.view subviews]) {
// Only remove the subviews with tag not equal to 1
if (subview.tag != 0)
{
[subview removeFromSuperview];
}
}
}
A big difference between the simulator and an actual device is that Mac OS (thus, also the simulator) is case insensitive, while the device is not.
The images are most probably not showing because you did not type them with the correct capitalization.
If you are sure that is not the problem, it would help to see your code.
it may be the problem with images , for testing try with only buttons (roundrect) and try in device without images. and if it work fine then there may be problem with images.
Can you please debug it on device if you know about it then it would be very easy to trace out the crase where it is crasing. As #antalkerekes said, if there is no issues regarding the case sensitivity then the app should work, but for your know do device testing.
Have the same behavior: UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; returns nothing (0x0) on iOS5.0 simulator, so buttons show up empty and, in this case, it has nothing to do with spelling/caps/lowercase etc. On the device everything is fine though.

Code works in sim, but only sometimes on device

The code to set image to imageView is:
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
SDWebImageManager *manager = [SDWebImageManager sharedManager];
UIImage *cachedImage = [manager imageWithURL:_url];
if (cachedImage)
{
_imageView.image = cachedImage;
[spinner stopAnimating];
}
else
{
[spinner startAnimating];
[manager downloadWithURL:_url delegate:self];
}
// Configure the view for the selected state
[super setSelected:selected animated:animated];
}
- (void)webImageManager:(SDWebImageManager *)imageManager
didFinishWithImage:(UIImage *)_image
{
[spinner stopAnimating];
_imageView.image = _image;
[self setNeedsLayout];
}
I use SDWebImage
this works every time in simulator, but when I run the app in the device (Ipod touch)
80 % of the images is just black, but if I go to another view and back the images are set (from cache).
I have try to set delay on _imageView = _image, but change.
(Answered in a question edit. Converted to a community wiki answer. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
Now I have try the code on a Iphone 3gs and it works perfect, can understand why it wont work on ipod touch.
When i Compiled and Run as "Release" it works on ipod, but not in as debugger. Wierd..

iPhone - performSelectorOnMainThread:#selector(setNeedsDisplay) doesn't work on iOS 4?

I have this really simply code:
myPageRef = CGPDFDocumentGetPage(myDocumentRef,CGPDFPageGetPageNumber(myPageRef)+1);
if (CGPDFPageGetPageNumber(myPageRef) == CGPDFDocumentGetNumberOfPages(myDocumentRef)) {
succBtn.enabled = NO;
}
precBtn.enabled = YES;
[tiledLayer performSelectorOnMainThread:#selector(setNeedsDisplay) withObject:0 waitUntilDone:NO];
That I used to browse a PDF document page by page.
This code works on iPhone 3.1.2 and above.
This code works on iPad too.
BUT ...
This code DOESN'T work on iOS4.
The performSelectorOnMainThread:#selector(setNeedsDisplay) doesn't fire the drawLayer method that let me draw the new page to display.
Can someone tell me why?????
Thanks-In-Advance.
It could be related to this race condition, do you implement an empty -drawRect:?