Strange leak when using QuickLook framework in iOS4.0 - iphone

I have used QuickLook framework for opening one 2 page pdf file modally, and everything works. However, after testing (Instruments Leaks) the project with different iOS versions and devices, I have noticed strange leak that was appearing when running Intruments leaks on iPhone 3GS + iOS 4.0 device. The leak was appearing after opening previewer modally on the parent view and closing previewer. Strange, but no leak was appearing when testing on simulator and iPhone 4 + iOS 5.0. I'm using Xcode 4.2.
The code is pretty straightforward. Here's a button action that opens previewer modally:
-(IBAction)openFiles:(id)sender{
QLPreviewController *preview = [[QLPreviewController alloc] init];
preview.dataSource = self;
preview.currentPreviewItemIndex = 0; //for previewing only one pdf file
[self presentModalViewController:preview animated:YES];
[preview release];
}
Here are the details for a leak in Instruments:

Related

iOS 6.1 UIWebview crashes when clicked on play youtube video inside a webpage

I am trying to show a website inside app. The website which i am trying to load has got a youtube video in it. The website loads properly in UIWebView and also lists the youtube video. But when I click on youtube video, the app crashes.
Crash log just says:
setting movie path: http://r19---sn-aig7knl7.c.youtube.com/videoplayback?...............
The website when loaded in Safari works fine, it even plays youtube video full screen.
Please help me in fixing this issue.
11 Feb 2013 - UPDATE
The issue is observed only on iOS Simulator 6.1. On Device everything works fine.
Detailed Info:
I have a custom UIViewController(TestWebViewController) which has an instance of UIWebView and implements UIWebViewDelegate. I have added a UIViewController in Storyboard and added UIWebView inside it, linked this UIViewController to my custom TestWebViewController and linked IBOutlet and delegate for UIWebView.
On Clicking a button, I am programmatically instantiating TestWebViewController using
TestWebViewController *testWebVC = [self.storyboard instantiateViewControllerWithIdentifier:#"testWebVC"];
testWebVC.view.frame = self.view.frame;
[testWebVC loadWebViewWithUrl:TEST_URL];
[self presentViewController:testWebVC animated:YES completion:nil];
As scott said in his comment, I removed my breakpoint for all exceptions and my error went away.
Hope this will help to others.
Modal view on iOS 5.0 and iOS 5.1 is the problem that causes crash on full screen video, AFAIK. They just changed hierarchy of views in that version of iOS (parentViewController and presentingViewController) and that is the aftermath. I asked about it long time ago here and one more same question is here and still no one knows what to do.
First of all, they fixed it in 6.0, I guess, that's good.
For 5.1 we changed design a little and avoided modal view. Do it, if it is possible in your situation.
TestWebViewController *testWebVC = [self.storyboard instantiateViewControllerWithIdentifier:#"testWebVC"];
[testWebVC LoadWebView:#"YOUR URL STRING"];
[self presentViewController:testWebVC animated:YES completion:nil];
AND in TestWebViewController class
-(void)LoadWebView:(NSString *)address {
addressStr = address;
}
- (void)viewDidLoad
{
[super viewDidLoad];
url = [NSURL URLWithString:addressStr];
NSURLRequest *request = [NSURLRequest requestWithURL:url] ;
[myWebView loadRequest:request] ;
}

phonegap iphone app showing black screen on iPad

I am developing and testing my iphone app (phonegap + native) properly on iPhone simulator and device.
However, when testing on iPad simulator or device, I can only see a blank black screen and no errors on console.
Target family is properly set to iPhone and window makeKeyAndVisible also executed! How to solve it?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIViewController *introVC = [[videoViewController alloc] initWithNibName:#"videoViewController" bundle:nil];
UIViewController *blogVC = [[blogViewController alloc] initWithNibName:#"blogViewController" bundle:nil];
NSArray *viewControllers = [NSArray alloc];
viewControllers = [NSArray arrayWithObjects: introVC, blogVC, nil];
[rootController setViewControllers:viewControllers animated:NO];
self.rootController.selectedIndex = 0;
[window setRootViewController:self.rootController];
[window makeKeyAndVisible];
return YES;
}
A black screen is pretty much always an error in the javascript. Assuming you are using iOS 6 you should be able to attach the desktop safari web inspector and look for any javascript errors, which will not show up in the Xcode console.
Another thing to test is that the app still works as a clean install on iPhone - updating an existing app only copies new and updated files, so errors caused by deletion such as renaming a script and leaving a reference to the old filename won't show up right away.

MFMessageComposeViewController on Simulator - canSendText?

following situation: I want to send in app SMS. This is my code creating the MFMessageComposeViewController:
-(void) showMessageComposerWithText:(NSString*)messageText telNumber:(NSString*)telNumber composeDelegate:(id)delegate
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = messageText;
controller.recipients = [NSArray arrayWithObject:telNumber];
controller.messageComposeDelegate = delegate;
[delegate presentModalViewController:controller animated:YES];
}
}
So I think this is straight forward. When testing in Simulator I get following exception: Application tried to push a nil view controller on target <MFMessageComposeViewController: 0x8a4e090>. I'm also wondering myself why [MFMessageComposeViewController canSendText] returns YES when running the app in the simulator.
When running on the device, everything is working correctly.
I couldn't find anything in the docs/web concerning this strange behavior.
I'm running Xcode 4.3 on OS 10.7.3, Deployment Target is iOS 5.0.
Thanks in advance,
tubtub
This problem occurs when you install Messages beta on OS X Lion.
Edit: It also occurs on Mountain Lion when there is an iMessage account configured and enabled. If the account is disabled, it works correctly (canSendText returns NO).
Tip: If you use controller.modalTransitionStyle = UIModalTransitionStylePartialCurl, you can go back in Simulator by clicking on the curled "page" in the upper left corner.
The simulator should always return NO from the canSendText, this isn't the case for the iOS 5.0 and 5.1 simulators. With Xcode 4.2 it crashed, on Xcode 4.3 it just pushes a nil view controller.
I'm seeing the same thing. I think it's a bug in the iOS 5 simulator with Xcode 4.3. canSendText correctly returns NO in the iOS 4.3 simulator. The same code works fine on the device.
With this configuration, canSendText returns correctly NO in the simulator (plus, a UIAlertView appears to say text messaging is not available):
Mountain Lion
Xcode 4.4,
iOS 5.1

App shows white screen on startup after upgrading to iOS 4.2

For the past few weeks I have been working on an app that uses a SoundManager class that I found via the comments of this blog post:
http://www.gehacktes.net/2009/03/iphone-programming-part-6-multiple-sounds-with-openal/
The link to the SoundManager and tester app is provided in the comments by David Evans. I am not allowed to provide a second link so I'll mention the name of ZIP file he links to:
SoundTester.zip
I was very happy with this code, until iOS 4.2 was released. After updating my iPad and Xcode correspondingly, my apps that use the SoundManager class only show the navigation bar with it's title. The rest of the screen is white. It's not iPad specific behavior. I have seen the same on an iPhone4 and an iPhone 3G that upgraded to iOS 4.2.
When running the apps in the simulator, I get the same results. The problem is that I get no error messages in the console window and no build and compile errors at all. Very frustrating and very hard to fix for an iPhone developer that started using the iPhone SDK only months ago.
Does anyone have a clue what could have gone broken and how to fix it? Any help is appreciated!
Somebody please shoot me...
Just found the problem, with the help from a piece of code I had written down from the iPhone Developer's Cookbook.
The problem was not the SoundManager (which still works fine, fortunately!) but in the application:didFinishLaunchingWithOptions: method in the App Delegate class.
Here is the code that causes the problem in iOS 4.2 but still works in iOS 3.2:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Create a Navigation Controller on the fly.
// Use the View Controller as root view controller.
viewController.title = #"ThreeSounds";
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];
nav.navigationBar.barStyle = UIBarStyleBlack;
// Add the view controller's view to the window and display.
[window addSubview:nav.view];
[nav release];
[window makeKeyAndVisible];
return YES;
}
The solution: remove the line that says: [nav release].
For some reason, releasing the navigation controller was not a problem in iOS 3.2.
In iOS 4.2 is makes the screen go white.
I found out that this method was the problem because it was the last method that was executed. That, in turn, I found out by adding this piece of code to every class in my project:
-(BOOL) respondsToSelector:(SEL)aSelector {
printf("SELECTOR: %s\n", [NSStringFromSelector(aSelector) UTF8String]);
return [super respondsToSelector:aSelector];
}
This piece of code logs all the methods that get called.
I used the following code in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions method
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
if (!window)
{
[self release];
return 0;
}
This method caused white screen when I launched my app. It was OK in 3.2 / 4.0 SDK. In SDK 4.3 it is causing the problem. Just comment or remove this code if you have it.
I had same problem. The problem was duplicated UIWindow.

"Symbol not found" error for UIPopoverController in an iPhone/iPad Universal App

In a universal binary iPhone/iPad app of mine, users are able to adjust preferences in a view controller that's presented modally.
On the iPhone, the settings panel is presented with presentModalViewController:animated:, and on the iPad, I use a UIPopoverController.
I'm having a heck of a time completely isolating the UIPopoverController code away from the iPhone code. Everytime I compile for the iPhone, I get the following error:
dyld: Symbol not found: _OBJC_CLASS_$_UIPopoverController
Referenced from: /var/mobile/Applications/CBB37F87-AA6D-47E2-823A-E259E3268A32/MyApp debug.app/MyApp
Expected in: /System/Library/Frameworks/UIKit.framework/UIKit
This is of course because UIKit on the iPhone doesn't have a UIPopoverController class. Does anybody have advice for how to effectively isolate the iPad API includes from the iPhone code, so I can actually run my code?
Ahhhh nevermind. Check out Apple's example app "TopPaid"
It's kinda hacky, but it works. Wish there was a more elegant solution...
Class cls = NSClassFromString(#"UIPopoverController");
if (cls != nil)
{
UIPopoverController *aPopoverController =
[[cls alloc] initWithContentViewController:self.masterViewController];
self.popoverController = aPopoverController;
[aPopoverController release];
[popoverController presentPopoverFromBarButtonItem:barButtonItem
permittedArrowDirections:UIPopoverArrowDirectionUp
animated:YES];
}