意外的标识符SLComposerView

时间:2018-02-20 13:54:53

标签: ios objective-c

嘿大家遇到重大错误,我被告知SLComposerViewController无法识别。当UIController正确写入时,没有可见的UIController接口和我的else语句中的预期标识符。它也没有认出我的actionContoller或我的twitterVC。我在学校,这是我给出的代码示例我已经检查了它并对其进行了三重检查,并且它逐字写入了构造示例,这让我感到困惑,因为总共有12个错误。任何人都可以帮我纠正这些错误的帮助会很棒!

//  ViewController.m
//  SocialNetworkApp
//
//  Created by Jessy on 2/12/18.
//  Copyright © 2018 A3LeversPeer. All rights reserved.
//

#import "ViewController.h"
#import "Social/Social.h"

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UITextView *tweetTextView;
- (void) configureTweetTextView;
- (void) showAlertMessage: (NSString *) myMessage;

@property (weak, nonatomic) IBOutlet UITextView *fbTextView;

@property (weak, nonatomic) IBOutlet UITextView *socialTextView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configureTweetTextView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void) showAlertMessage:(NSString *) myMessage {
    UIAlertController *alertController;
    alertController = [UIAlertController alertControllerWithTitle:@"TwitterShare" message:myMessage preferredStyle: UIAlertControllerStyleAlert];
    [alertController addAction: [UIAlertAction actionWithTitle:@"Okay" style:UIAlertActionStyleDefault handler:nil]];
    [self presentViewController:alertController animated:YES completion:nil];
}

- (IBAction)tweetShareAction:(id)sender {

    if ([self.tweetTextView isFirstResponder]) {
        [self.tweetTextView resignFirstResponder];
}

UIAlertController *actionController = [UIAlertController alertControllerWithTitle:@"" message:@"Tweet Notes" preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *cancelAction =[UIAlertAction actionWithTitle:@"Cancel" style: UIAlertActionStyleDefault handler:nil];

    UIAlertAction *tweetAction =[UIAlertAction actionWithTitle:@"Tweet"style: UIAlertActionStyleDefault handler:
                                 ^(UIAlertAction *action) {
if([SLComposeViewController
        isAvailableForServiceType:SLServiceTypeTwitter]
(SLComposeViewController *twitterVC= [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]);
}];
    //Tweet Out
    if( [self.tweetTextView.text length] <140 ) {
    [twitterVC setInitialText:self.tweetTextView.text];
}
        else{
NSString *shortText = [self.tweetTextView.text substringToIndex:140];
}

[self.presentedViewController: twitterVC animated:YES completion:nil];
}

else{
    //Raise Objection

    [self showAlertMessage:@"Sign in to Twitter"];
[actionController addAction:tweetAction];
[actionController addAction:cancelAction];

[self presentViewController:actionController animated:YES completion:nil];

- (void) configureTweetTextView {
    self.tweetTextView.layer.backgroundColor =[UIColor colorWithRed: 0.98
                green: 0.80                                                                                       blue: 0.93
                    alpha: 1.0].CGColor;

    self.tweetTextView.layer.cornerRadius= 10.0;
    self.tweetTextView.layer.borderColor= [UIColor colorWithWhite: 0
                                                            alpha: 0.5].CGColor;
    self.tweetTextView.layer.borderWidth= 2.0;
}

- (IBAction)fbShareAction:(id)sender {
}
- (IBAction)socialShareAction:(id)sender {
}
- (IBAction)nothingShareAction:(id)sender {
}


@end

1 个答案:

答案 0 :(得分:1)

尝试替换:

#import "Social/Social.h"

人:

#import <Social/Social.h>

社交是Apple的框架,因此您应该使用<>符号导入它。

顺便说一下,检查 Social.framework 中包含的Target -> General -> Linked Frameworks and Libraries