This code is crashing when i run my app on iOS6 Simulator with Xcode 4.5 GM Seeds:
if ([[[UIDevice currentDevice] systemVersion] isEqualToString:#"6.0"]) {
XLog(#"hier checken");
self.tabBarController = [[UITabBarController alloc] init];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
}
[...]
self.loginController = [[[LoginController alloc] initWithNibName:#"LoginController_iPhone" bundle:nil] autorelease];
self.loginController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
//this line occurs a crash on iOS 6 (simulator, device not tested)
[self.tabBarController presentViewController:self.loginController
animated:YES
completion:nil];
The crash is a SIGABRT. no more information about the crash.
what is occuring this crash on iOS6?
initWithNibName:bundle: is the designated initializer for a UIViewController,and there is something new in iOS6 .
You can try to modify your LoginController_iPhone.xib and remove its controller :
---->
It works for me .
hope this helps.
An app i was working on, would crash without any trace when I was trying to access the address book. ABAddressBookRef or ABAddressBookCreate with the permission for your app to access Contacts turned off, will crash the app. Hope this helps!
Related
Does Gluon Mobile have any guidance on implementing a share button? My goal is to be able to share a string containing a link to different apps on the phone. At the moment, I need this only for the iOS implementation. I was able to find this link that provides a simple way to do this in Objective-C:
- (IBAction)shareButton:(UIBarButtonItem *)sender
{
NSString *textToShare = #"Look at this awesome website for aspiring iOS Developers!";
NSURL *myWebsite = [NSURL URLWithString:#"http://www.codingexplorer.com/"];
NSArray *objectsToShare = #[textToShare, myWebsite];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
NSArray *excludeActivities = #[UIActivityTypeAirDrop,
UIActivityTypePrint,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo];
activityVC.excludedActivityTypes = excludeActivities;
[self presentViewController:activityVC animated:YES completion:nil];
}
Looking at the GoNative application example on the Gluon website, it seems like I can use the above code snippet where needed as the native iOS code. Do I have to update the ios build gradle to account for the UIActivity class mentioned in the first link above?
Update*
I have been able to get this to work based on help in this question here.
However when trying to install the native library, I get this error which is understandable as self is unknown in the scope of the code. How would I be able to do this? Instantiate a popover or dialog and pass the activityVC to it?
/Users/ashishsharma/NetBeansProjects/konfamdbranch/src/ios/native/Share.m:25:6: error: use of undeclared identifier 'self' [self presentViewController:activityVC animated:YES completion:nil];
So I was able to solve this using examples on the internet (shown above) along with going through the existing code for the Barcode Scan Service. The issue I was experiencing with the above code was that the present view controller could not be found. However, looking at the bit bucket source for Barcode Scan, I was able to get the root view with the following code:
if(![[UIApplication sharedApplication] keyWindow])
{
NSLog(#"key window was nil");
return;
}
// get the root view controller
UIViewController *rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
if(!rootViewController)
{
NSLog(#"rootViewController was nil");
return;
}
Then in the code snippet I placed in the question, replace self with rootViewController:
[rootViewController presentViewController:activityVC animated:YES completion:nil];
This leads to the modified code snippet:
#import <UIKit/UIKit.h>
#include "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h"
JNIEXPORT void JNICALL Java_com_gluonhq_charm_down_plugins_ios_IOSShareService_shareMessage
(JNIEnv *env, jclass jClass, jstring jMessage) {
if(![[UIApplication sharedApplication] keyWindow])
{
NSLog(#"key window was nil");
return;
}
// get the root view controller
UIViewController *rootViewController = [[[UIApplication sharedApplication] keyWindow] rootViewController];
if(!rootViewController)
{
NSLog(#"rootViewController was nil");
return;
}
NSString *textToShare = #"Check out this site!";
NSURL *myWebsite = [NSURL URLWithString:#"http://www.google.com/"];
NSArray *objectsToShare = #[textToShare, myWebsite];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
NSArray *excludeActivities = #[UIActivityTypeAirDrop,
UIActivityTypePrint,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo];
activityVC.excludedActivityTypes = excludeActivities;
[rootViewController presentViewController:activityVC animated:YES completion:nil];
}
Note I followed the GoNative application to generate my objective-c/ios files correctly.
This leads to a minimal functionality share implementation only because I don't have Facebook installed on the IPhone simulator.
My iphone app use camara to take photo.
Installing the app on ipad, the access to camara make the app crash.
Someone knows if any difference exists on use the picker controller between iphone and ipad?
Tx in advance
---EDIT---
he codeo that thaht call the camara I using is:
- (void) showCamera{
UIImagePickerController * imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.allowsEditing =YES;
[self presentViewController:imagePickerController animated:YES completion:nil];
}
I added UIScreen bounds code in AppDelegate.m for iPhone 6 and now device orientation for iPhone 6 won't work for Portrait/ Upside Down. Upside Down is what's not working in simulator and devices.
Code in AppDelegate.m
CGSize iosScreenSize = [[UIScreen mainScreen] bounds].size;
if (iosScreenSize.height == 667) {
UIStoryboard *iPhone6 = [UIStoryboard storyboardWithName:#"iPhone6" bundle:nil];
UIViewController *initialViewController =[iPhone6 instantiateInitialViewController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];
self.window.rootViewController = initialViewController;
[self.window makeKeyAndVisible];
}
When I included the above code the simulator and device for iPhone 6 doesn't detect Upside Down orientation. I also used nativeBounds and screenBounds, didn't work either for Upside Down orientation.
My code for device orientation...
-(NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
I have no idea what to do to get AppDelegate code to let UpSide Down orientation be detected for iPhone 6.
OK, finally figured this one out.
Then realized someone posted the answer here: Setting device orientation in Swift iOS
Go down to DaRk-_-D0G's answer.
I had to subclass my tab bar controller just to override that method. Very obnoxious .
I have a small png that I am adding to a view which I am pretty sure I had working previously but suddenly stopped working on the iPad itself while continuing to work fine on the iPad simulator.
Here is the code I am using to add the image to the view...
UIImageView *bottomResizer = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"resizeLine.png"]];
bottomResizer.center = CGPointMake(bottomResizer.center.x, bottomResizer.center.y+self.frame.size.height-12);
bottomResizer.tag = 301;
[self addSubview:bottomResizer];
[bottomResizer release];
This occurs in a UIGestureRecognizerStateBegan event. The following code in removes the image in a touchesEnded event without any errors even though you cannot see it.
NSArray *subViews = [self subviews];
int count = [subViews count];
for (int i =count-1; i>=0; i--) {
if([[subViews objectAtIndex:i] tag] == 301) {
[[subViews objectAtIndex:i] removeFromSuperview];
}
}
I don't think it is anything I changed in my code since it works in the simulator. Not sure where to look next for the problem. I have reset the simulator to see if it would break after a reset. I have also cleaned the project.
Thanks.
John
Put a breakpoint AFTER this line UIImageView *bottomResizer = [[UIImageView alloc]...
Then on the console "po [bottomResizer image]"
If it is nil then either the resource is not getting copied correctly into the bundle OR you could have a corrupt image that the device cannot load.
(IBAction)switchAppointment {
AppointmentController *appt = [[AppointmentController alloc] initWithNibName:nil bundle:nil];
appt.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:appt animated:YES];
[appt release];
}
That is the code that I use to switch from one .xib to another, however on the line that says "self presentModalViewController:appt animated:YES" , I'm getting a SIGABRT error. My app crashes immediately when I try to go into that interface.
FYI too I'm on Xcode 4.2, but it was doing this before I downloaded the beta.
I have also same answer for the code:
nextView *second=[[nextView alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:second animated:YES];
[second release];
Yours
Miska