UIActivityViewController doesn't work in iOS 8 - ios8

I was using UIActivityViewController to share something for my application. It works well in any device prior to iOS8. The problem is the text,images are not be shown in email, twitter, Facebook in iOS 8 device or simulator.
Here is my code:
NSString *textObject = #"Test";
NSString *urlString = #"http://test.com";
UIImage* image = [UIImage imageNamed:#"logo"];
NSURL *url = [NSURL URLWithString:urlString];
NSArray *activityItems = [NSArray arrayWithObjects:textObject, url, image, nil];
UIActivityViewController *avc = [[UIActivityViewController alloc]
initWithActivityItems:activityItems
applicationActivities:nil];
avc.excludedActivityTypes = #[UIActivityTypePostToWeibo, UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard ];
[self presentViewController:avc animated:YES completion:nil];
Did I do anything wrong? Thanks.
EDIT:
The new Xcode 6.1 and iOS 8.1 doesn't solve the problem. And it causes crash in email. Here are some screenshots (take email sharing as an example):
In iOS 7 (You can see the image)
In iOS 8 (Blank screen)
And the app crashes with a "MailCompositionService" exception. The
part of the error message is:
Process: MailCompositionService [3775] Path:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/Applications/MailCompositionService.app/MailCompositionService
Identifier: MailCompositionService Version:
1.0 (1.0) Code Type: X86-64 (Native) Parent Process: launchd_sim [3725] Responsible: launchd_sim [3725] User ID:
501
Date/Time: 2014-10-22 10:31:19.064 +0800 OS Version:
Mac OS X 10.10 (14A389) Report Version: 11 Anonymous UUID:
B1EC6B56-DD7F-36A3-1506-B8CE84AB3FEB
Time Awake Since Boot: 9800 seconds
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT) Exception Codes:
0x0000000000000000, 0x0000000000000000
Application Specific Information:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSRegularExpression
enumerateMatchesInString:options:range:usingBlock:]: nil argument'
terminating with uncaught exception of type NSException abort() called
CoreSimulator 110.4 - Device: iPhone 6 - Runtime: iOS 8.1 (12B411) -
DeviceType: iPhone 6

It seems to be correct in real device but not in simulator.

I am encountering the same issue. however mine is slightly different. I can present the the controller without any actions available. :/ I have remove all of the excludedtypes hoping that I can see any but fails. I guess this is another bug with the latest release of xcode 6.1 and iOS8.

Related

after i've upgraded to iOS version 7.1 my iOS app crashing on iPad 2 only, works fine on all other devices

I've an iOS app for iPad & iPhone.
My app worked fine on all devices until now .
Now (after i've upgraded to iOS version 7.1) it crashes on ipad2 only.
On all other devices it has no problem.
At the startup of the app (and before calling viewDidLoad ).
I have this error:
(appDelegate Log)close didFinishLaunchingWithOptions
2014-04-02 20:37:14.677 xxx[6436:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(0x2e438fd3 0x38f1bccf 0x2e372f9d 0x30d7bd89 0x30f229ff 0x30ce1589 0x30c5930d 0x30c59289 0x30c5fed9 0x30c5d847 0x30cc735d 0x30cc3fcd 0x30cbe58b 0x30c5a709 0x30c59871 0x30cbdcc9 0x33267aed 0x332676d7 0x2e403ab7 0x2e403a53 0x2e402227 0x2e36cf4f 0x2e36cd33 0x30cbcef1 0x30cb816d 0x441a9 0x44130)
libc++abi.dylib: terminating with uncaught exception of type NSException
I cannot understand why.
Thanks in advance.
-------- EDITED --------
I've solved by removing a unused button from the main View:
/* #synthesize myButton;*/
- (void)viewDidUnload {
/* [self setMyButton:nil]; */
}

SIGABRT on Startup in Simulator

I was just running my code on the simulator which has been working in the past. The only thing I've really done for the startup code is setting user defaults
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:
#"Automatic", #"userType",
#"NO", #"autoRefresh",
#"60", #"refreshInt", nil
];
[defaults registerDefaults:appDefaults];
[defaults synchronize];
I ran the app 10 times on my iPhone/iPad and experienced no crashing on startup. However, if I run it on the iPhone/iPad Simulator, the iPhone simulator crashes with SIGABRT basically every other time. I am not sure what's causing this as I've already restarted my computer and did a "Reset all Contents and settings" on the simulator.
Thanks!
Alan
If you are running Xcode 4.6.2 on OSX 10.8.4, try upgrading to Xcode 4.6.3 which was just released a few days ago. The 4.6.3 version has fixes for the random crashes and hangs that sometimes happens when debugging on the ios simulator.
This seems to be a bug in the lldb in chord with the newest version of Moutain Lion. If you want to avoid this switch to using GDB

UIPopover with UIDatePicker throws exception in iOS5.1

I have an enterprise iPad app that runs on several iPads of different vintage. All work fine except for one which is the only 1st generation iPad in the group. This iPad is running iOS 5.1.1. The app uses a UIPopoverController in several places and all work fine on this iPad except for the one that I last created.
Using the iPad 5.1 Simulator I was able to duplicate the problems…
The app crashes when trying to open a UIPopoverController which contains a UIViewController contining a UIDatePicker and a UIButton. The exception reads…
* Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named NSLayoutConstraint'
Here is the code I am using up to the line that throws the exception…
DatePickerPopOverViewController *datePickerViewController =[[DatePickerPopOverViewController alloc] init];
datePickerViewController.defaultDate = lastPopoverDate;
datePickerViewController.buttonTitle = #"Get Schedule";
datePickerViewController.delegate = self;
UIPopoverController *datePickerPopOver = [[UIPopoverController alloc] initWithContentViewController:datePickerViewController];
I am pretty sure that all of the elemnts involved are available in iOS5.1. Any suggestions would be greatly appreciated.
John
You can not use autolayout below iOS 6.0. The exception you are seeing is a result of this. NSLayoutConstraint is the class used to define interface element relationships when using autolayout.
To continue to target versions below iOS 6.0, simply uncheck "Use Autolayout" in the IB interface.

Xcode keeps crashing

I just started out programming for iOS. I tried adding an enter button for a simple calculator and changing its size, but Xcode keeps crashing. This is the report:
Process: Xcode [406]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 4.5.1 (1842)
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Application Specific Information:
ProductBuildVersion: 4G1004
ASSERTION FAILURE in /SourceCache/IDEInterfaceBuilderCocoaTouch/IDEInterfaceBuilderCocoaTouch-1929/IBPlugin/Utilities/IBObjectMarshalling.m:651
Details: Failed to arbitrate IBNSLayoutConstraint, IBUIButton, IBUILabel, IBUIView, and IBUIViewController.
Interface Builder encountered an error communicating with the iOS Simulator. If you choose to file a crash report or radar for this issue, please check Console.app for crash reports for "Interface Builder Cocoa Touch Tool" and include their content in your crash report.
Exception name: IBAssertionFailure
Exception reason: ASSERTION FAILURE:
Reason: All views needing candidate constraints have already had constraints generated. This most likely indicates a bug involving layout of the following views:
Layout engine frame ({{20, 20}, {282, 36}}) of <UILabel: 0x81f5560; frame = (20 20; 281 36); text = '0'; clipsToBounds = YES; opaque = NO; autoresize = TM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x815cdd0>> does not match canvas frame ({{20, 20}, {281, 36}})
I've already tried reinstalling Xcode and resetting iOS simulator as well. I have Mountain Lion.
Try this steps:
1) Right click on Storyboard in the navigator
2) Click on Show File Inspector
3) Uncheck "Use Autolayout"
Hope this helps

iOS App Crashing on iOS 4.2 but not 4.0, simulator not showing logs

Using XCode 3.2.5 I can run my application on iOS Simulator using the 4.2 SDK. However, it crashes on the following function, more specifically, the presentModalViewController call:
- (void)login {
//check to see if they logged in correctly here
/*UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:#"Login Failed!"
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];*/
[self presentModalViewController:self.accountsViewController animated:YES];
}
However, on XCode 4 Dev Preview, I can't even access 4.2 SDK in the Simulator, so I'm forced to use 4.0 SDK. In 4.0, that function works find and as expected. I have two issues:
Why is the 4.2 SDK in the Simulator not reporting the reason it crashed in XCode 3.2.5? It used to be that when my app would crash in debugging mode in the Simulator, XCode would pop up the reason. However, it's not anymore.
Why would that simple line crash in 4.2 but not 4.0. Could it be the different XCode versions?
It was some sort of weird issue between XCode version. I recreated the whole add using solely XCode 3.2.5 and the same exact code now works.

Resources