gpt4 book ai didi

ios - 意外的标识符 SLComposerView

转载 作者:行者123 更新时间:2023-11-29 11:36:35 24 4
gpt4 key购买 nike

大家好,遇到重大错误时我被告知 SLComposerViewController 无法识别。 UIController 没有可见的接口(interface),如果正确编写,我的 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

最佳答案

尝试替换:

#import "Social/Social.h"

通过:

#import <Social/Social.h>

Social 是 Apple 的框架,所以你应该用 <> 导入它。签名。

顺便检查一下你的Target -> General -> Linked Frameworks and Libraries您包含在 Social.framework 中。

关于ios - 意外的标识符 SLComposerView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48886911/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com