in our iPad-App we are using an UIWebView to load different sites from one domain some of them with a hml5-Video.
Sites without a Video do load perfectly. But when I'm loading a site containing htmlt5-video sometimes my app
crashes during the loading-process of the UIWebView with EXC_BAD_ACCESS and sometimes it does not. Whenever such a crash occurs it seems to happen at the point where the Video-Player is added into the site.
I did download the UICatalog-Example from Apple and just did change the Default-URL in the WebViewController-Class to a URL of a site containg html5-video. Same results ... sometimes crash sometimes no crash.
I also did create a New Project on Xcode (View-based Application - for iPad) and only did add a UIWebView to the new Projects ViewController. Again ... loading a site containing html5-video sometimes leads to a crash and sometimes not.
CODE FROM "NEW PROJECTS" VIEWCONTROLLER (IMPLEMENTATION):
- (void)viewDidLoad {
[super viewDidLoad];
self.myWebView = [[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 768, 1004)] autorelease];
self.myWebView.backgroundColor = [UIColor whiteColor];
self.myWebView.scalesPageToFit = YES;
self.myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.myWebView.delegate = self;
[self.view addSubview: self.myWebView];
[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.gelbeseiten.de/129103114849"]]];
//More Sites with HTML5-Videos ...
//[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.gelbeseiten.de/129103746403"]]];
//[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"http://www.gelbeseiten.de/129105233646"]]];
}
- (void)viewDidUnload {
[super viewDidUnload];
self.myWebView = nil;
}
- (void)viewWillDisappear:(BOOL)animated {
[self.myWebView stopLoading];
}
- (void)dealloc {
myWebView.delegate = nil;
[myWebView release];
[super dealloc];
}
CODE FROM "NEW PROJECTS" VIEWCONTROLLER (HEADER):
#interface WebViewTestViewController : UIViewController <UIWebViewDelegate> {
UIWebView *myWebView;
}
#property (nonatomic, retain) UIWebView *myWebView;
DEVICE LOGS:
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000098
Crashed Thread: 0
Thread 0 Crashed:
0 WebCore 0x34c7d09e WebCore::RenderLayer::clippingRoot() const + 110
1 WebCore 0x34c7cf2a WebCore::RenderLayer::childrenClipRect() const + 26
2 WebCore 0x34c7ce0c WebCore::RenderWidget::setWidgetGeometry(WebCore::IntRect const&) + 40
3 WebCore 0x34c5e0f8 WebCore::RenderWidget::updateWidgetPosition() + 320
4 WebCore 0x34ba0170 WebCore::RenderView::updateWidgetPositions() + 144
5 WebCore 0x34b97d16 WebCore::FrameView::performPostLayoutTasks() + 202
6 WebCore 0x34b8a6c0 WebCore::FrameView::layout(bool) + 2116
7 WebCore 0x34bc5244 WebCore::FrameView::forceLayout(bool) + 4
8 WebKit 0x302c0c24 -[WebHTMLView layoutToMinimumPageWidth:height:maximumPageWidth:adjustingViewSize:] + 136
9 WebKit 0x302c0b8e -[WebHTMLView layout] + 18
10 WebKit 0x302c26f2 -[WebHTMLView(WebInternal) _layoutIfNeeded] + 50
11 WebKit 0x302c2622 -[WebHTMLView(WebInternal) _web_layoutIfNeededRecursive] + 14
12 WebKit 0x302c251e -[WebHTMLView(WebPrivate) viewWillDraw] + 50
13 CoreFoundation 0x3581dfc0 -[NSObject(NSObject) performSelector:] + 12
14 CoreFoundation 0x35826d4a -[NSArray makeObjectsPerformSelector:] + 382
15 WebCore 0x34bb000c -[WAKView viewWillDraw] + 24
16 CoreFoundation 0x3581dfc0 -[NSObject(NSObject) performSelector:] + 12
17 CoreFoundation 0x35826d4a -[NSArray makeObjectsPerformSelector:] + 382
18 WebCore 0x34bb000c -[WAKView viewWillDraw] + 24
19 CoreFoundation 0x3581dfc0 -[NSObject(NSObject) performSelector:] + 12
20 CoreFoundation 0x35826d4a -[NSArray makeObjectsPerformSelector:] + 382
21 WebCore 0x34bb000c -[WAKView viewWillDraw] + 24
22 CoreFoundation 0x3581dfc0 -[NSObject(NSObject) performSelector:] + 12
23 CoreFoundation 0x35826d4a -[NSArray makeObjectsPerformSelector:] + 382
24 WebCore 0x34bb000c -[WAKView viewWillDraw] + 24
25 WebKit 0x302c24cc -[WebView(WebPrivate) viewWillDraw] + 56
26 WebCore 0x34bafec0 WebCore::TileCache::prepareToDraw() + 36
27 WebCore 0x34bafe6e -[TileLayer display] + 26
28 QuartzCore 0x31079fb0 CALayerDisplayIfNeeded + 176
29 QuartzCore 0x3106f56e CA::Context::commit_transaction(CA::Transaction*) + 214
30 QuartzCore 0x3106f37c CA::Transaction::commit() + 184
31 QuartzCore 0x31092f96 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 46
32 CoreFoundation 0x3580ac52 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 10
33 CoreFoundation 0x3580aac6 __CFRunLoopDoObservers + 406
34 CoreFoundation 0x358020c4 __CFRunLoopRun + 848
35 CoreFoundation 0x35801c80 CFRunLoopRunSpecific + 224
36 CoreFoundation 0x35801b88 CFRunLoopRunInMode + 52
37 GraphicsServices 0x320c84a4 GSEventRunModal + 108
38 GraphicsServices 0x320c8550 GSEventRun + 56
39 UIKit 0x341dc322 -[UIApplication _run] + 406
40 UIKit 0x341d9e8c UIApplicationMain + 664
41 WebViewTest 0x00002c24 0x1000 + 7204
42 WebViewTest 0x00002bd8 0x1000 + 7128
Can anybody give me an idea?
Thanks in advance, Florian
There is a little trick to override this crash. If you slightly scroll the webview just before the video content is loaded, the crash can be avoided. Before trying it out from code, try scrolling the webView a bit on device with your finger. It won't crash now.
In code, do something like this:
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[webView stringByEvaluatingJavaScriptFromString:#"window.scrollTo(0, 10);"];
}
to simulate a scroll on the webview through javascript. The scroll value can be as low as 1, so the user won't notice the scroll at all.
Telling the webview to evaluate any JavaScript (or none at all) on webViewDidFinishLoad: seems work (albeit hacky).
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[webView stringByEvaluatingJavaScriptFromString:#""];
}
Seems I've solved this issue...
i've moved all HTML-5 video tags insertion in Javascript
function placeVideoTag() {
var val = '<video />';
var el = document.getElementById('video-id');
el.innerHTML = val;
}
And i'm calling JS in [UIWebView didFinishLoad]
- (void)webViewDidFinishLoad:(UIWebView *)aWebView {
[aWebView stringByEvaluatingJavaScriptFromString:#"placeVideoTag()"];
}
Works perfectly in my case.
Other suggestions didn't work for me.
I have exactly the same problem. no answer yet. Saw many others reports similar problems - iOS 4.2.1 only.
Basically, I have a UIView Controller with a webview as its subview, and load a URLRequest to a youtube link.
The first time I load the viewController, the console logs error "Unable to read symbols for /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.2.1 (8C148)/Symbols/System/Library/Internet Plug-Ins/QuickTime Plugin.webplugin/QuickTime Plugin (file not found).". I stop loading and release the viewController. The second time I re-load new viewController with the same request to that youtube link, now the app crashed with EXC_BAD_ACCESS
Thanks, for your posts!!! In my case it only works with different quite high offset-values for Portrait- and Landscape-Mode on iPad
(Portrait-Mode: greater than 60; Landscape-Mode: greater than 780):
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
if (self.interfaceOrientation == UIInterfaceOrientationPortrait ||
self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
[webView stringByEvaluatingJavaScriptFromString:#"window.scrollTo(0, 60);"];
} else if (self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
self.interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
[webView stringByEvaluatingJavaScriptFromString:#"window.scrollTo(0, 780);"];
}
webView.loadCounter--;
}
But with this solution my app crashes by double-tapping to zoom during the loading-process of a site.
I did subclass UIWebView to solve this problem (to prevent webView from zooming while loading):
.m:
#synthesize loadCounter;
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
CGPoint p = currentPoint;
NSTimeInterval t = currentTimestamp;
currentPoint = point;
currentTimestamp = [event timestamp];
if (CGPointEqualToPoint(p, point) &&
[event timestamp] - t < 0.2 && loadCounter > 0){
return self.superview;
}
return [super hitTest:point withEvent:event];
}
.h:
#interface NonDoubleTapableWhileLoadingWebView : UIWebView {
CGPoint currentPoint;
NSTimeInterval currentTimestamp;
NSInteger loadCounter;
}
#property (assign) NSInteger loadCounter;
And added a counter to determine the last "didFinish"-call and to reactivate the double-tapping possibility
(init loadCounter with 0)
- (void)webViewDidStartLoad:(UIWebView *)webView {
linkWebView.loadCounter++;
}
Related
I am using a UINavigationController as rootviewController and storyboard segue for pushingViewController. I have many viewcontrollers in my app. I pass them using push view controller only.
Crash scenario: (can reproduce)
I have a Products list viewController and I will navigate to products detail viewController when I tap on product in the list using tap Gesture recognizer.
From the detail view controller, I will be pushed to cart item viewController which displays all selected products when I tap a button named 'Addd to cart'.
If I try to pay for all the products I want to choose a contact from the people picker, when I press pay button, it will present peopelpickerController as modalViewController and when I choose a contact it gets crashed.
Crash occurs only when move to and fro from products list view controlelr to peoplepicker contoller. When I debugged using instrument I got crash saying deallocated instance receiving message.
I have included the method where I am getting crash. But i never tried to call the method from any controller.
Code...
//choosing contact and people picker delegate
- (IBAction) chooseContacts: (id) sender {
picker = [
[ABPeoplePickerNavigationController alloc] init];
picker.peoplePickerDelegate = self;
[self presentViewController: picker animated: YES completion: nil];
}
#pragma mark - Addressbook delegate methods
- (void) peoplePickerNavigationControllerDidCancel: (ABPeoplePickerNavigationController * ) peoplePicker {
[self dismissViewControllerAnimated: YES completion: nil];
}
- (BOOL) peoplePickerNavigationController: (ABPeoplePickerNavigationController * ) peoplePicker
shouldContinueAfterSelectingPerson: (ABRecordRef) person {
[self dismissViewControllerAnimated: YES completion: ^ {
[self displayPerson: person];
}];
return NO;
}
Crash occurs in the below method at the line performSegueWithIdentifier,
#pragma mark- Tap gesture delegates
-(void)tapGestureFirstImage:(UITapGestureRecognizer *)sender
{
UIImageView *image = (UIImageView *)sender.view;
if (image.tag < [_productsArray count]) {
[MBProgressHUD showHUDAddedTo:self.view animated:YES];
productDetailDictionary = [_productsArray objectAtIndex:image.tag];
NSLog(#"%#",productDetailDictionary);
[self performSegueWithIdentifier:#"productDetailSeague" sender:sender];
}
NSLog(#"imageView.Tag %ld",(long)image.tag);
}
Crash Log:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 0
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x39cb11fc __pthread_kill + 8
1 libsystem_pthread.dylib 0x39d1aa2e pthread_kill + 54
2 libsystem_c.dylib 0x39c61ff8 abort + 72
3 libc++abi.dylib 0x38f90cd2 abort_message + 70
4 libc++abi.dylib 0x38fa96e0 default_terminate_handler() + 248
5 libobjc.A.dylib 0x396f291e _objc_terminate() + 190
6 libc++abi.dylib 0x38fa71c4 std::__terminate(void (*)()) + 76
7 libc++abi.dylib 0x38fa6a18 __cxa_throw + 112
8 libobjc.A.dylib 0x396f277e objc_exception_throw + 246
9 CoreFoundation 0x2ef5be88 +[NSException raise:format:] + 100
10 UIKit 0x317b9590 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 496
11 UIKit 0x317b7dce -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2054
12 UIKit 0x317b6e20 -[UIViewController presentViewController:withTransition:completion:] + 4664
13 UIKit 0x31992cae -[UIViewController presentModalViewController:animated:] + 26
14 DHCC Events 0x0008f0c0 0x38000 + 356544
15 libdispatch.dylib 0x39bd5d18 _dispatch_call_block_and_release + 8
16 libdispatch.dylib 0x39bdbd16 _dispatch_after_timer_callback$VARIANT$mp + 46
17 libdispatch.dylib 0x39bd5d04 _dispatch_client_callout + 20
18 libdispatch.dylib 0x39bde7fe _dispatch_source_invoke$VARIANT$mp + 258
19 libdispatch.dylib 0x39bdc73a _dispatch_main_queue_callback_4CF$VARIANT$mp + 186
20 CoreFoundation 0x2ef26814 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 4
21 CoreFoundation 0x2ef250e8 __CFRunLoopRun + 1296
22 CoreFoundation 0x2ee8fc22 CFRunLoopRunSpecific + 518
23 CoreFoundation 0x2ee8fa06 CFRunLoopRunInMode + 102
24 GraphicsServices 0x33b8327e GSEventRunModal + 134
25 UIKit 0x31733044 UIApplicationMain + 1132
26 DHCC Events 0x00041ad6 0x38000 + 39638
27 libdyld.dylib 0x39bfaab4 start + 0
Appreciate your help.
On -(void)tapGestureFirstImage:(UITapGestureRecognizer *)sender
you perform the segue with
[self performSegueWithIdentifier:#"productDetailSeague" sender:sender];
but I think the sender should be self and not sender..
UPDATE
Do you try to perform segue while picker is active? In this case self may be deallocated, so you can try to perform segue after picker is dismissed:
[picker dismissViewControllerAnimated:YES completion:^{[self performSegueWithIdentifier:#"productDetailSeague" sender:self];}];
I have run into some kind of crash, here is the crash stack:
WebCore 0x353c81b4 WebCore::PageCache::markPagesForFullStyleRecalc(WebCore::Page*) + 20
WebKit 0x36a6a45f -[WebView(WebPrivate) _initWithFrame:frameName:groupName:usesDocumentViews:] + 139
WebKit 0x36a6a3cd -[WebView initWithFrame:frameName:groupName:] + 53
WebKit 0x36a6a393 -[WebView initWithFrame:] + 47
UIKit 0x37251bfb -[UIWebDocumentView initWithWebView:frame:] + 287
UIKit 0x372828d1 -[UIWebBrowserView initWithWebView:frame:] + 57
UIKit 0x37282891 -[UIWebDocumentView initWithFrame:] + 41
UIKit 0x37282809 -[UIWebBrowserView initWithFrame:] + 49
UIKit 0x37437d73 -[UIWebView _webViewCommonInitWithWebView:scalesPageToFit:shouldEnableReachability:] + 235
UIKit 0x374385a9 -[UIWebView initWithFrame:] + 81
SeMob 0x001c216d -[SeMobWebInternalView initWithFrame:] (SeMobWebInternalView.m:64)
SeMob 0x001e7761 -[SeMobWebReader prepareReaderInWebView:] (SeMobWebReader.m:102)
SeMob 0x000eeb0d -[SeMobWebView webViewDidFinishLoad:] (SeMobWebView.m:1475)
CoreFoundation 0x346979c4 __invoking___ + 68
CoreFoundation 0x345eefeb -[NSInvocation invoke] + 287
CoreFoundation 0x345eeb43 -[NSInvocation invokeWithTarget:] + 51
WebKit 0x36a6189b -[_WebSafeForwarder forwardInvocation:] + 375
CoreFoundation 0x3469661b ___forwarding___ + 627
CoreFoundation 0x345edf68 __forwarding_prep_0___ + 24
CoreFoundation 0x346979c4 __invoking___ + 68
CoreFoundation 0x345eefeb -[NSInvocation invoke] + 287
WebCore 0x354197eb _ZL11SendMessageP12NSInvocation + 27
WebCore 0x35456fa5 _ZL20HandleDelegateSourcePv + 81
CoreFoundation 0x34669683 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
CoreFoundation 0x34668ee9 __CFRunLoopDoSources0 + 213
CoreFoundation 0x34667cb7 __CFRunLoopRun + 647
CoreFoundation 0x345daebd CFRunLoopRunSpecific + 357
CoreFoundation 0x345dad49 CFRunLoopRunInMode + 105
GraphicsServices 0x353432eb GSEventRunModal + 75
UIKit 0x37220301 UIApplicationMain + 1121
SeMob 0x000d48a7 main (main.m:12)
and two pieces of code:
- (void)prepareReaderInWebView:(UIWebView *)webView
{
// ...omit some code here
if ([readableContent length]) {
self.innerWebView = [[[SeMobWebInternalView alloc] initWithFrame:webView.bounds] autorelease];
innerWebView.scalesPageToFit = NO;
innerWebView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
innerWebView.scrollView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
innerWebView.scrollView.scrollsToTop = YES;
innerWebView.delegate = self;
...
}
#interface SeMobWebInternalView : UIWebView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
UIMenuItem *flag =
[[UIMenuItem alloc] initWithTitle:#"search" action:#selector(search:)];
...
}
the crash always occers in the super's init method. Why it always crash? Plz help me !
Apple documentation says that UIWebView should not be subclassed:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIWebView_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006950-CH3-DontLinkElementID_2
Check subclassing notes.
As #cosmin stated your not meant to subclass UIWebView, from your code it looks like your trying to customize the appearance. try this code instead:
webView.backgroundColor = [UIColor clearColor]; // changes to clear colour
webView.opaque = NO;
for(UIView *innerView in [[[webView subviews] objectAtIndex:0] subviews]) { // Hide images that make shadow
if ([innerView isKindOfClass:[UIImageView class]]) {
innerView.hidden = YES;
}
}
I am creating my first iPhone app in which the first screen displays a table view the user selects from. It works before localization using the method below.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
navigationController = [[UINavigationController alloc] init];
[self.window addSubview:[self.navigationController view]];
if(self.selectCategoryViewController == nil)
{
SelectCategoryViewController *viewTwo = [[SelectCategoryViewController alloc] initWithNibName:#"SelectCategoryViewController" bundle:[NSBundle mainBundle]];
self.selectCategoryViewController = viewTwo;
[viewTwo release];
}
[self.navigationController setNavigationBarHidden:YES];//this will hide the navigation bar
[self.navigationController pushViewController:self.selectCategoryViewController animated:YES];
//self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
After I localized it by adding the Japanese localization file and changing the above to this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
navigationController = [[UINavigationController alloc] init];
[self.window addSubview:[self.navigationController view]];
if(self.selectCategoryViewController == nil)
{
NSBundle *myLocalizedBundle=[NSBundle bundleWithPath:[NSString stringWithFormat:[[NSBundle mainBundle]bundlePath],"en.lproj"]];
NSLog(#"the localized bundle is %#",myLocalizedBundle);
SelectCategoryViewController *viewTwo=[[SelectCategoryViewController alloc] initWithNibName:#"SelectCategoryViewController" bundle:myLocalizedBundle];
self.selectCategoryViewController = viewTwo;
[viewTwo release];
}
[self.navigationController setNavigationBarHidden:YES];//this will hide the navigation bar
[self.navigationController pushViewController:self.selectCategoryViewController animated:YES];
[self.window makeKeyAndVisible];
return YES;
}
it crashes with the following error:
√sh.app> (loaded)
2013-02-18 18:04:35.196 PictureEnglish[5529:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFString substringFromIndex:]: Range or index out of bounds'
*** Call stack at first throw:
(
0 CoreFoundation 0x012775a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x013cb313 objc_exception_throw + 44
2 CoreFoundation 0x0122fef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x0122fe6a +[NSException raise:format:] + 58
4 Foundation 0x00033086 -[NSString substringFromIndex:] + 133
5 PictureEnglish 0x00008524 -[SelectCategoryViewController viewDidLoad] + 937
6 UIKit 0x00378089 -[UIViewController view] + 179
7 UIKit 0x00376482 -[UIViewController contentScrollView] + 42
8 UIKit 0x00386f25 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
9 UIKit 0x00385555 -[UINavigationController _layoutViewController:] + 43
10 UIKit 0x00386870 -[UINavigationController _startTransition:fromViewController:toViewController:] + 524
11 UIKit 0x0038132a -[UINavigationController _startDeferredTransitionIfNeeded] + 266
12 UIKit 0x0049c2e9 -[UILayoutContainerView layoutSubviews] + 226
13 QuartzCore 0x010a7a5a -[CALayer layoutSublayers] + 181
14 QuartzCore 0x010a9ddc CALayerLayoutIfNeeded + 220
15 QuartzCore 0x0104f0b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
16 QuartzCore 0x01050294 _ZN2CA11Transaction6commitEv + 292
17 UIKit 0x002ca9c9 -[UIApplication _reportAppLaunchFinished] + 39
18 UIKit 0x002cae83 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690
19 UIKit 0x002d5617 -[UIApplication handleEvent:withNewEvent:] + 1533
20 UIKit 0x002cdabf -[UIApplication sendEvent:] + 71
21 UIKit 0x002d2f2e _UIApplicationHandleEvent + 7576
22 GraphicsServices 0x01bcf992 PurpleEventCallback + 1550
23 CoreFoundation 0x01258944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
24 CoreFoundation 0x011b8cf7 __CFRunLoopDoSource1 + 215
25 CoreFoundation 0x011b5f83 __CFRunLoopRun + 979
26 CoreFoundation 0x011b5840 CFRunLoopRunSpecific + 208
27 CoreFoundation 0x011b5761 CFRunLoopRunInMode + 97
28 UIKit 0x002ca7d2 -[UIApplication _run] + 623
29 UIKit 0x002d6c93 UIApplicationMain + 1160
30 PictureEnglish 0x00001cec main + 102
31 PictureEnglish 0x00001c7d start + 53
32 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
Any suggestions on how I should call the SelectCategoryViewController for the selected language?
This line looks wrong to me:
NSBundle *myLocalizedBundle=[NSBundle bundleWithPath:[NSString stringWithFormat:[[NSBundle mainBundle]bundlePath],"en.lproj"]];
You probably meant something like this:
NSString* path= [[NSBundle mainBundle] pathForResource:#"en" ofType:#"lproj"];
NSBundle* bundle:myLocalizedBundle = [NSBundle bundleWithPath:path];
SelectCategoryViewController *viewTwo = [[SelectCategoryViewController alloc] initWithNibName:#"SelectCategoryViewController" bundle:myLocalizedBundle];
This is discussed more here: Manually loading a different localized nib in iOs
Note that this is only required if you want to do an in-app language selection. Localization should typically use the iOS device's selected language, in which case all this is much more straightforward (you simply let iOS pick the bundle for you).
xcode 5:
i had to clean build, clean build folder,delete derived data, reset simulator, close simulator, close Xcode.
Open project again and it's working.
Problem - This is a problem of project path, I think [self.window makeWindowKeyVisible] can not be able to find a path to your first assigned controller...
Solution - It happens some time, when your project suddenly stopped work, So no worries - just shift your project to other path, or just change the name of folder where actually your project resides and it will started working fine....
It works for me successfully...
I use UIWebView to load this site http://www.xiami.com/song/1024665
sometimes my app crashes if I touch the view or play the audio in this site and sometimes it does not, why?
is it because html5? how to solve?
other website is no problem.
crash log is
* -[MPTransportButton _isChargeEnabled]: message sent to deallocated instance 0x20aa58d0
any help is much appreciated
---update---
I create a new view-base project, the code in ViewController is as following
This time, the crash log is
2011-08-16 18:11:25.450 WebTest[1291:707] -[__NSCFDictionary _isChargeEnabled]: unrecognized selector sent to instance 0x1ede0a10
2011-08-16 18:11:25.462 WebTest[1291:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary _isChargeEnabled]: unrecognized selector sent to instance 0x1ede0a10'
*** Call stack at first throw:
(
0 CoreFoundation 0x30ea764f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x349c2c5d objc_exception_throw + 24
2 CoreFoundation 0x30eab1bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x30eaa649 ___forwarding___ + 508
4 CoreFoundation 0x30e21180 _CF_forwarding_prep_0 + 48
5 UIKit 0x30f232bd -[UIWindow warpPoint:] + 200
6 UIKit 0x30f0c1d5 _UIApplicationHandleEvent + 2404
7 GraphicsServices 0x30790e77 PurpleEventCallback + 666
8 CoreFoundation 0x30e7ea97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
9 CoreFoundation 0x30e8083f __CFRunLoopDoSource1 + 166
10 CoreFoundation 0x30e8160d __CFRunLoopRun + 520
11 CoreFoundation 0x30e11ec3 CFRunLoopRunSpecific + 230
12 CoreFoundation 0x30e11dcb CFRunLoopRunInMode + 58
13 GraphicsServices 0x3079041f GSEventRunModal + 114
14 GraphicsServices 0x307904cb GSEventRun + 62
15 UIKit 0x30f37d69 -[UIApplication _run] + 404
16 UIKit 0x30f35807 UIApplicationMain + 670
17 WebTest 0x00013425 main + 48
18 WebTest 0x000133f0 start + 40
)
terminate called after throwing an instance of 'NSException'
the source code in the project, not use MPMoviePlayerController this time or something else
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [self init];
return self;
}
- (id)init
{
if (self = [super initWithNibName:nil bundle:nil])
{
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIWebView *web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
[web loadRequest:[NSURLRequest requestWithURL:
[NSURL URLWithString:#"http://www.xiami.com/song/1024665"]]];
web.delegate = self;
[self.view addSubview:web];
[web release];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
//[webView stringByEvaluatingJavaScriptFromString:#"window.scrollTo(0, 10);"];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
}
There's nothing wrong in code that you posted.
NSZombie says that there is a MPTransportButton somewhere in your code that was previously deallocated (released) and after that, somewhere else in your code, you want to do something with it.
I think that you do it in one of your UIWebView's delegate methods.
But... we need more code. Where do you alloc/init your MPMoviePlayerController? Or do you alloc/init a MPTransportButton?
I have this crash. It is similar to other threads, but not the same.
I would like to show a modal view controller first the user goes to a specific view controller. Following the hints, I do that on - (void) viewDidAppear:(BOOL)animated, and apply a delay as I saw it's recommended.
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self performSelector:#selector(presentMyModal) withObject:nil afterDelay:1];
}
- (void) presentModal{
ModalViewController *modal = [[[ModalViewController alloc] init] autorelease];
[self presentModalViewController:modal animated:YES];
}
Afterwards, ramdomly It crashes. I get this message in console:
<Warning>: *** Assertion failure in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:], /SourceCache/UIKit/UIKit-1447.6.4/UIWindowController.m:186
Thu Feb 3 10:00:44 unknown MyApp[1830] <Error>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal transition from <UINavigationController: 0x454260> to <ModalViewController: 0x47af00> while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed'
*** Call stack at first throw:
(
0 CoreFoundation 0x3759dc7b __exceptionPreprocess + 114
1 libobjc.A.dylib 0x32d9bee8 objc_exception_throw + 40
2 CoreFoundation 0x3759dac3 +[NSException raise:format:arguments:] + 70
3 Foundation 0x351a3e73 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 62
4 UIKit 0x359e92a8 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 208
5 UIKit 0x359e8c98 -[UIViewController presentModalViewController:withTransition:] + 2792
6 UIKit 0x35a7b51c -[UIViewController _tryRecursivelyPresentModalViewController:withTransition:] + 116
7 UIKit 0x359e84c0 -[UIViewController presentModalViewController:withTransition:] + 784
8 UIKit 0x359e8060 -[UIViewController presentModalViewController:animated:] + 96
9 MyApp 0x0005d57f -[MyAppViewController presentMyModal] + 58
10 Foundation 0x351724db __NSFireDelayedPerform + 366
11 CoreFoundation 0x37552305 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 16
12 CoreFoundation 0x37551cd9 __CFRunLoopDoTimer + 988
13 CoreFoundation 0x37521a91 __CFRunLoopRun + 1184
14 CoreFoundation 0x3752150b CFRunLoopRunSpecific + 226
15 CoreFoundation 0x37521419 CFRunLoopRunInMode + 60
16 GraphicsServices 0x33e76d24 GSEventRunModal + 196
17 UIKit 0x3591d57c -[UIApplication _run] + 588
18 UIKit 0x3591a558 UIApplicationMain + 972
19 MyApp 0x0000e75f main + 50
20 MyApp 0x0000e6e8 start + 52
As you can see, I wait until view is appeared. Is this maybe an OS bug? It seems like it tries to present recursively other modal view controllers, provoquing crashes.
Thanks a lot.
Apart from me being picky in the comment, I thought I could as well help with this one as well. I think you need to search for the culprit somewhere else. I created a new project and a view controller with this snippet:
#import "VC1.h"
#implementation VC1
- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self performSelector:#selector(presentModal) withObject:nil afterDelay:1.0];
}
- (void)presentModal {
static int colorChooser = 0;
VC1 *vc1 = [[[VC1 alloc] init] autorelease];
switch (colorChooser%2) {
case 0:
vc1.view.backgroundColor = [UIColor whiteColor];
break;
default:
vc1.view.backgroundColor = [UIColor blackColor];
break;
}
colorChooser++;
[self presentModalViewController:vc1 animated:YES];
}
#end
And it works flawlessly after being pushed on the navigation controller. It is recursively alternating between black and white views, tested both in the sim and on a 3G device.
Maybe you are doing some other view transitions due to some notifications or other asynchronic means? Either way you would need to share more of your code for anyone to tell where the problem is.
Our preferred solution is to use -[UIViewController presentViewController:animated:completion:] and do whatever the next action is (eg presenting another VC) in the completion block.
For example:
[self presentViewController:yourViewController animated:YES completion:^{
[yourViewController presentMyModal];
}];
This method was introduced in iOS 5.0.