简体   繁体   中英

Adding a Hashtag to a Twitter Post

I'm using TWTweetComposeViewController to allow the user to send tweets from my application. Since the goal is foster communication between people using the app, all tweets should have a specific hash-tag appended to each tweet. I've read the Twitter TOS, so obviously this can't be done "below the table." The TOS does allow you to add content to a tweet if you ask first, however.

I'm wanting to simply have it visibly concatenate the tag to whatever the user writes in the tweet window, and make it irremovable - that way the user knows it's being sent, and it counts properly towards the character counters.

What's the best way to do it? Subclassing TWTweetComposeViewController? Rolling my own? Is there a better way to "tag" all the tweets from this app that's less obtrusive than a hashtag?

为什么不只将最大字符输入减少#标签长度,并制作一个UI标签或其他内容来显示它,以直观地暗示您将在其推文中添加内容?

As you realise you can pre-populate the TWTweetController with text , attached images and attached URLS so you can pre-populate the text with your hashtag but once you show it you have no control over what the user eventually does with the text content including deleting your hashtag.

The only way to achieve what you want; "unremovable hashtags" is to roll your own controller.

TWTweetController seems to use quite a bit of Apples private magic so I wouldn't like to try subclassing especially as it seems to change with each OS release. Note what happens now when you start typing @references. That never used to happen in the 5.0 versions. In other words if you subclass it I wouldn't be surprised when it breaks with an OS release.

So weigh up the cost of developing and QA'ing your own Twitter engine against using a free and solid module and letting your users delete your hashtags that they might not want to use.

You could do this with DETweetComposeViewController . It's an open source replacement for Apple's routines, so it works with iOS 4, and you can completely customize it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM