How do I program a share button ? xcode [closed] - ios

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I found a repository on gifthub that is exactly what i was looking for. Can you help me how to code this to work with a single button. I don't enough experience yet with ios programmin to do this. I almost finished building my first app, but i need help with this.
Thanks in advance
https://github.com/BobDG/BDGShare

For a beginner I suggest this..
Its much easier. Just a few lines of code.
- (IBAction)shareButtonPressed:(id)sender {
NSLog(#"shareButton pressed");
NSString *texttoshare = #"text to share";
UIImage *imagetoshare = [UIImage imageNamed:#"beck.png"];
NSArray *activityItems = #[texttoshare, imagetoshare];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo];
[self presentViewController:activityVC animated:TRUE completion:nil];
}

Related

UIActivityViewController not Sharing both Text and Image on Facebook [duplicate]

Please, can you tell me if I'm doing mistakes?
NSString *sharedMsg=[NSString stringWithFormat:#"Hello world"];
UIImage* sharedImg=[UIImage imageNamed:#"image"];
NSArray* sharedObjects=[NSArray arrayWithObjects:sharedMsg, sharedImg, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc]
initWithActivityItems:sharedObjects applicationActivities:nil];
activityViewController.popoverPresentationController.sourceView = self.view;
[self presentViewController:activityViewController animated:YES completion:nil];
At runtime when I select the icon of Facebook the text is missing, the image is correctly displayed.
My xcode is 6.3.1, tested on iPad.
It seems that a recent update to the Facebook application has replaced the in-built Facebook share activity with one that ignores status text - If you remove the Facebook app from your device the text will be displayed using the code you have. If you have the Facebook app installed you get images, URLs but not the text
Facebook's policies don't allow you to pre-populate status messages and require all content to be user generated - while I understand the intention behind this, I personally think it is kind of stupid in many cases - For example in my game I want to pre-populate the user's score, but now I can't, so the user is presented with an empty dialog box. I will probably simply remove the Facebook sharing option as no-one will ever use it now.
This response from Facebook confirms that the behaviour is by design
Here is the answer in Swift. It may not help your problem, but it might be helpful with someone looking for this title. Just create a button and it's action. And install the button's action like this.
Note: You have to log in your facebook or twitter by going to setting. Then do like this.
#IBAction func onShareTouched(sender: AnyObject) {
print("share")
let myShare = "My beautiful photo! <3 <3"
let image: UIImage = UIImage(named: "yourImageNameHere")
let shareVC: UIActivityViewController = UIActivityViewController(activityItems: [(image), myShare], applicationActivities: nil)
self.presentViewController(shareVC, animated: true, completion: nil)
}
NSString* text=#"Hello world";
NSURL *myWebsite = [NSURL URLWithString:#"http://www.website.com/"];
// UIImage * myImage =[UIImage imageNamed:#"myImage.png"];
NSArray* sharedObjects=#[text,myWebsite];
UIActivityViewController * activityViewController=[[UIActivityViewController alloc]initWithActivityItems:sharedObjects applicationActivities:nil];
activityViewController.popoverPresentationController.sourceView = self.view;
[self presentViewController:activityViewController animated:YES completion:nil];

More beautiful way to do if-statement behaviour [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I have a method in my app that checks to see if some things are true.
- (BOOL)isToggleTurnedOn {
return ([self checkToggleStatus] != [self checkOtherToggle]);
}
When this method returns true, I display a modal.
if ([Preferences isToggleTurnedOn] == true) {
NSArray *welcomeTexts = #[
...
some data
...
];
WelcomeController *welcomeController = [[WelcomeController alloc] initWithText:welcomeTexts];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:whatsNewController];
navController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:navController animated:YES completion:nil];
}
Now, this code is not as beautiful as it could by, in my opinion. I'd rather add the presentation of the controller as a parameter of isToggleTurnedOn. What's the best way to refactor this?
- (BOOL)isToggleTurnedOn {
return [self checkToggleStatus] != [self checkOtherToggle]
}
Drives me crazy to see code like this. Be more succinct:
- (BOOL)isToggleTurnedOn {
return ([self checkToggleStatus] != [self checkOtherToggle]);
}

Multi Image Picker objective-c [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
In my application i want that user should be able to select multiple images from his gallery, but using UIImagePickerController we can select only 1 image at a time.
And as i am a fresher and don't have much knowledge of objective-c i am not able to implement Multi image picker components available on GitHub like- MAImagePicker, QBImagePicker, ELCImagePickerController.
If anyone has used any of these components kindly provide me with sample code and steps to implement that.
use ELCImagePicker
https://github.com/B-Sides/ELCImagePickerController
download from github and import in your project.
add select image button
- (IBAction)selectImg:(id)sender
{
ELCImagePickerController *elcPicker = [[ELCImagePickerController alloc] initImagePicker];
elcPicker.maximumImagesCount = 100; //Set the maximum number of images to select to 100
elcPicker.returnsOriginalImage = YES; //Only return the fullScreenImage, not the fullResolutionImage
elcPicker.returnsImage = YES; //Return UIimage if YES. If NO, only return asset location information
elcPicker.onOrder = YES; //For multiple image selection, display and return order of selected images
elcPicker.mediaTypes = #[(NSString *)kUTTypeImage, (NSString *)kUTTypeMovie]; //Supports image and movie types
elcPicker.imagePickerDelegate = self;
[self presentViewController:elcPicker animated:YES completion:nil];
}
get images from this methods.
- (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info
{
[self dismissViewControllerAnimated:YES completion:nil];
for (NSDictionary *dict in info)
{
if ([dict objectForKey:UIImagePickerControllerMediaType] == ALAssetTypePhoto)
{
if ([dict objectForKey:UIImagePickerControllerOriginalImage])
{
UIImage* image=[dict objectForKey:UIImagePickerControllerOriginalImage];
[arrImgs addObject:image];
}
}
}
}
- (void)elcImagePickerControllerDidCancel:(ELCImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:nil];
}

iOS: How to share text and image on social networks?

Please, can you tell me if I'm doing mistakes?
NSString *sharedMsg=[NSString stringWithFormat:#"Hello world"];
UIImage* sharedImg=[UIImage imageNamed:#"image"];
NSArray* sharedObjects=[NSArray arrayWithObjects:sharedMsg, sharedImg, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc]
initWithActivityItems:sharedObjects applicationActivities:nil];
activityViewController.popoverPresentationController.sourceView = self.view;
[self presentViewController:activityViewController animated:YES completion:nil];
At runtime when I select the icon of Facebook the text is missing, the image is correctly displayed.
My xcode is 6.3.1, tested on iPad.
It seems that a recent update to the Facebook application has replaced the in-built Facebook share activity with one that ignores status text - If you remove the Facebook app from your device the text will be displayed using the code you have. If you have the Facebook app installed you get images, URLs but not the text
Facebook's policies don't allow you to pre-populate status messages and require all content to be user generated - while I understand the intention behind this, I personally think it is kind of stupid in many cases - For example in my game I want to pre-populate the user's score, but now I can't, so the user is presented with an empty dialog box. I will probably simply remove the Facebook sharing option as no-one will ever use it now.
This response from Facebook confirms that the behaviour is by design
Here is the answer in Swift. It may not help your problem, but it might be helpful with someone looking for this title. Just create a button and it's action. And install the button's action like this.
Note: You have to log in your facebook or twitter by going to setting. Then do like this.
#IBAction func onShareTouched(sender: AnyObject) {
print("share")
let myShare = "My beautiful photo! <3 <3"
let image: UIImage = UIImage(named: "yourImageNameHere")
let shareVC: UIActivityViewController = UIActivityViewController(activityItems: [(image), myShare], applicationActivities: nil)
self.presentViewController(shareVC, animated: true, completion: nil)
}
NSString* text=#"Hello world";
NSURL *myWebsite = [NSURL URLWithString:#"http://www.website.com/"];
// UIImage * myImage =[UIImage imageNamed:#"myImage.png"];
NSArray* sharedObjects=#[text,myWebsite];
UIActivityViewController * activityViewController=[[UIActivityViewController alloc]initWithActivityItems:sharedObjects applicationActivities:nil];
activityViewController.popoverPresentationController.sourceView = self.view;
[self presentViewController:activityViewController animated:YES completion:nil];

Universal App about view controllers [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i just want to ask about the universal app that i have created a universal app with two different storyboard one for iphone and other for ipad , lets assume i created a viewcontroller in both storyboards called mainview so should i create different classes for the storyboard of iphone and ipad or should i create one class and assign to both mainview iphone and mainview ipad .
ignore the code below
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:[NSString stringWithFormat:#"%#",[ApplicationUtility getPlistData:KEY_REGISTER_DATA]] delegate:self cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
NSString *str = [NSString stringWithFormat:#"%#",[ApplicationUtility getPlistData:KEY_REGISTER_DATA]];
NSLog(#"%#",str);
if([str isEqualToString:#"Signed up successful"])
{
username.text = #"";
firstname.text = #"";
lastname.text = #"";
email.text = #"";
supass.text = #"";
suconfirmpass.text = #"";
country.text = #"";
postal.text = #"";
dob.text = #"";
titl.text = #"";
[priv1 setSelected:NO];
[priv2 setSelected:NO];
[male setSelected:NO];
[female setSelected:NO];
}
Yes you should create one class for both storyboards if you can, so if you have any special treatment for any, you can put some if statements in your code.
You can take a look at Apple's doc here.
in storyboard u should call a ipad storybard on ipad condition and u shoud call iphone storyboard on iphone condition and condition is below...
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad)
{
//for iphone storyboard
}
else
{
//for ipad storyboard
}

Resources