Why is there no text being shown while tweeting? - iphone

The initial text isn't being shown, did I type something wrong or missing something? I followed a tutorial exactly and no beans.
if ([TWTweetComposeViewController canSendTweet]) {
TWTweetComposeViewController *tweetComposer=[[TWTweetComposeViewController alloc]init];
[self presentModalViewController:tweetComposer animated:YES];
[tweetComposer setInitialText:#"#VOX"];
}
I am trying to get this to run on ios5.1

Looks like you might have to call setInitialText before you present the TWTweetComposeViewController. so you would have:
if ([TWTweetComposeViewController canSendTweet]) {
TWTweetComposeViewController *tweetComposer=[[TWTweetComposeViewController alloc]init];
[tweetComposer setInitialText:#"#VOX"];
[self presentModalViewController:tweetComposer animated:YES];
}
According to the docs for TWTweetComposeViewController setInitialText: Will return a NO if text does not fit in the currently available character space or the view was presented to the user.

Related

Obj C Modal box with options to call or email

Hi everyoneI need some direction on how to go about accomplishing a task. I have a app with 5 tab bar items I need to program one of the tabs to call a modal dialog box that has three options. 1. Cancel 2. Call Us 3. Email Us. if the user pushes call us the device should start calling our 800 number if they press email us then it should open the email client and put our sales or support team automatically in the "to:" section. Please provide me with some direction or perhaps a tutorial on how to something like this. Thank you for your help.
I have added these tasks in a different view using two UIButtons. if you come up with a way to do a popOver please let me know. If not I will go with what I have. Thank you. The code I used for email and call (both can be found by doing a SO search) in case anyone else looks in on this thread are as follows:
EMAIL
-(IBAction)emailUs:(id)sender
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailViewcontroller = [[MFMailComposeViewController alloc]init];
mailViewcontroller.mailComposeDelegate = self;
[mailViewcontroller setToRecipients:[NSArray arrayWithObjects:#"CustomerService#laserpros.com", nil]];
[mailViewcontroller setTitle:#"Email Us"];
[mailViewcontroller setSubject:#"Email Us"];
[mailViewcontroller setMessageBody:#"Your message goes here" isHTML:NO];
[self presentViewController:mailViewcontroller animated:YES completion:nil];
}
else
{
NSLog(#"Device is unable to send email in its current state.");
}
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
[self dismissViewControllerAnimated:YES completion:nil];
}
CALL
-(IBAction)callUs:(id)sender
{
NSURL *phoneNumber = [NSURL URLWithString:#"telprompt://18885585277"];
[[UIApplication sharedApplication] openURL:phoneNumber];
}

How to share app

I'm developing an app. I'm going to publish to an app store. But client needs to share this app with friends. I have a button to share my app. How to share the app? I read some doc they mentioned, use [[UIApplication SharedApplication] openURL:#" url"]. I don't have my app URL. Because I didn't submit the app. Is it possible to share my app?
If you want to know what the URL of your application will be before it has been submitted/approved, Apple provides a shorthand URL you can use, of the form:
http://itunes.com/apps/appname
For example:
http://itunes.com/apps/AngryBirds
If you want the specific URL with the application ID, you could submit v1.0.0 without the "Share" link, then immediately submit a 1.0.1 update with the link included.
Url can be generated via app id. Its the best way to do it coz if app name changes, url could change. But app id wont change.
You can get your app id on itunesConnect.apple.com or via itunes.
//https://itunes.apple.com/app/id_hereisyourappID
Let see how to do the sharing.
I will show you 4 ways to share your link. Via Facebook, Twitter, Mail and SMS.
For Facebook and Twitter.
Add Accounts and Social framework. And in your header import.
#import <Social/Social.h>
#import <Accounts/Accounts.h>
when you want to share link use the following code
SLComposeViewController *mySLComposerSheet = [[SLComposeViewController alloc] init];
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];//for twitter use SLServiceTypeTwitter
[mySLComposerSheet addURL:[NSURL URLWithString:#"https://itunes.apple.com/app/id123456789"]];
[self presentViewController:mySLComposerSheet animated:YES completion:nil];
Lets do it with mail add MessageUI framework and import
#import <MessageUI/MessageUI.h>
And the delegate MFMailComposeViewControllerDelegate
in your code
MFMailComposeViewController* mailComposer = [[MFMailComposeViewController alloc] init];
[mailComposer setMailComposeDelegate:self];
[mailComposer setModalPresentationStyle:UIModalPresentationFormSheet];
[mailComposer setMessageBody:#"https://itunes.apple.com/app/id123456789" isHTML:NO];
[self presentViewController:mailComposer animated:YES completion:nil];
And add delegate method
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[controller dismissViewControllerAnimated:YES completion:nil];
}
You can create html content for mail body.
Lets share it via SMS
Add delegate MFMessageComposeViewControllerDelegate
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = #"https://itunes.apple.com/app/id123456789";
controller.messageComposeDelegate = self;
[self presentViewController:controller animated:YES completion:nil];
}
And add delegate method.
-(void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[controller dismissViewControllerAnimated:YES completion:nil];
}
I hope this helps.

Twitter in iOS 5 leaking memory with ARC

Here is my code:
case kTweetIndex:
{
TWTweetComposeViewController *tweetSheet =
[[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:[NSString stringWithFormat:#"%#",self.item.link]];
[self presentModalViewController:tweetSheet animated:YES];
if (![TWTweetComposeViewController canSendTweet])
{
NSLog(#"Can't Send tweet");
}
}
This is just a massive amount of leak caused by twitter, and i don't know how to handle it. Thanks!
Make Property of TWTweetComposeViewController or twitter class or you can one thing more alloc it in AppDelegate Class. It will work.

TWTeetComposeViewController execute custom code after posting a new tweet

So, using the new Twitter framework in iOS5, we can simply post Twitter updates with this simple code:
if ([TWTweetComposeViewController canSendTweet]) {
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:#"Tweeting from Steamerduck :)"];
[controller presentModalViewController:tweetSheet animated:YES];
}
However, I would like to execute some custom code after a user clicks on send here:
Is it possible to execute some custom code, some of my own methods after the TWTweetComposeViewController sends a tweet?
You can specify a completion handler that gets called after the user is done composing the tweet. It would look something like this (I haven't had a chance to test this on a device yet):
if ([TWTweetComposeViewController canSendTweet]) {
TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:#"Tweeting from Steamerduck :)"];
// Set a completion handler to be called when the user is done
// composing their tweet
[tweetSheet setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
if (result == TWTweetComposeViewControllerResultDone) {
// Tweet was sent, do something
} else if (result == TWTweetComposeViewControllerResultCancelled) {
// Do something else if the user cancelled
[controller dismissModalViewControllerAnimated:YES];
}
}];
[controller presentModalViewController:tweetSheet animated:YES];
}

UIScrollView and presentModalViewController

I add UITableViewController in UIScrollView. When I call
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:#"Email"];
[picker setMessageBody:currentcelltext isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
MFMailComposeViewController is coming in UIScrollView. So, I can't press cancel and send button.
How to fix it ?
I hope that you set MessageUI.framework in your xcode project..
After you have to set delegate in .h file..
than ,
you have to create one more method..
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
[self becomeFirstResponder];
[self dismissModalViewControllerAnimated:YES];
}
You might have fixed the issues.
This answer is for those who might come to this post with the expectation of answer.
To fix this you have to use delegation pattern. I assume all the pages in your scrollview are viewcontroller instances and scrollview is subview to viewcontroller.
This answer https://stackoverflow.com/a/626946/451867 can help you to implement delegate pattern in your project,
You can read developer docs for more info - docs