首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Obj C- UITextViewDelegate不兼容类型警告

Obj C- UITextViewDelegate不兼容类型警告
EN

Stack Overflow用户
提问于 2011-04-11 21:45:29
回答 2查看 5K关注 0票数 0

journalComment.delegate =self行上的警告:从不兼容的类型'JournalEntryViewController*‘向'id’赋值

journalComment是一个textView。

我不确定警告是关于什么的,它应该只是说-警告:“新手在键盘上,去上一些obj c课程。”

谢谢你的帮助。

代码语言:javascript
复制
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        // Hide keyboard when done key is pressed

        // define the area and location for the UITextView
        CGRect tfFrame = CGRectMake(0, 0, 320, 460);
        journalComment = [[UITextView alloc] initWithFrame:tfFrame];
        // make sure that it is editable
        journalComment.editable = YES;

        // add the controller as the delegate
        journalComment.delegate = self;

    }
    return self;
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-04-11 21:52:24

您的类必须符合UITextViewDelegate协议,因此在.h文件中使其看起来像

代码语言:javascript
复制
@interface JournalEntryViewController : NSViewController <UITextViewDelegate>
{

...

}

然后,编译器将知道您的类符合该协议。当然,您仍然需要实现所需的方法。

票数 10
EN

Stack Overflow用户

发布于 2011-04-11 21:53:51

您从中发布示例代码的对象需要实现UITextViewDelegate协议。为此,您的.h文件应以以下内容开头:

代码语言:javascript
复制
@interface MyViewController : UIViewController <UITextViewDelegate>

然后,您需要在.m文件中实现协议的方法(请参阅Apple Developer Docs)。这是必需的,但您可能会对一些委托回调函数感兴趣。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5622224

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档