我正在尝试将本机iOS Twitter帐户实现统一。我找到了一个通过Xcode使用原生社交帐户的代码,所以我试图让它与团结沟通,但我得到了这个错误:“使用未声明的标识符'self'”
这是我的代码:
extern "C"
{
void _PushTwitter(const char * messageTweet)
{
//Check Twitter accessibility and at least one account is setup.
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *tweetSheet =[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
//This is setting the initial text for our share card.
[tweetSheet setInitialText:[NSString stringWithUTF8String:messageTweet]];
//Brings up the little share card with the test we have pre defind.
[self presentViewController:tweetSheet animated:YES completion:nil];
} else {
//This alreat tells the user that they can't use built in socal interegration and why they can't.
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You can't send a tweet right now, make sure you have at least one Twitter account setup and your device is running the latest iOS version" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil];
[alertView show];
}
}
}
我在[self presentViewController ...]部分得到错误。
这是原始代码:
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
//Each button title we gave to our action sheet is given a tag starting with 0.
if (buttonIndex == 0) {
//Check Twitter accessibility and at least one account is setup.
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *tweetSheet =[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
//This is setting the initial text for our share card.
[tweetSheet setInitialText:@"veasoftware.com made it easy to intergate Twitter with iOS 6! :D "];
//Brings up the little share card with the test we have pre defind.
[self presentViewController:tweetSheet animated:YES completion:nil];
} else {
//This alreat tells the user that they can't use built in socal interegration and why they can't.
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry" message:@"You can't send a tweet right now, make sure you have at least one Twitter account setup and your device is using iOS6." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}
}
非常感谢任何帮助。
编辑/解决方案:对于任何感兴趣的人,我发现这篇文章更容易整合(可能是唯一一个):http://www.theappguruz.com/unity/share-image-and-text-on-twitter-in-ios-using-native-code/就像一个魅力。我正在运行iOS 8,Unity 5和最新版本的Xcode。
答案 0 :(得分:0)
您找到的代码可能是objective-c类的一部分,其中定义了 self ,它指向当前对象。
您编写的代码似乎不是类的方法,而是全局函数,这意味着它没有附加对象。
你应该将你找到的代码添加到Unity为你定义的类之一,也许是在UnityAppController.mm中