UITextView里面的UIScrollView不是第一反应 [英] UITextView inside UIScrollView is not First Responder

查看:142
本文介绍了UITextView里面的UIScrollView不是第一反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在Interface Builder中将UITextView嵌入UIScrollView内部时,UITextView不再是第一个响应者。响应者。我不知道发生了什么变化?



我想让UITextView成为第一个响应者。 b $ b

   - (void)viewDidLoad {
[super viewDidLoad];
[scrollView setContentSize:CGSizeMake(540,620)];
composeTextView.delegate = self;
[composeTextView becomeFirstResponder];
}


解决方案

这是我的.h文件:

  #import< UIKit / UIKit.h> 

@interface Untitled1ViewController:UIViewController< UITextFieldDelegate> {
UIScrollView * scrollView;
UITextField * composeTextView;
}

@property(nonatomic,retain)IBOutlet UIScrollView * scrollView;
@property(nonatomic,retain)IBOutlet UITextField * composeTextView;

@end

这是我的.m文件:

  #importUntitled1ViewController.h

@implementation Untitled1ViewController
@synthesize scrollView;
@synthesize composeTextView;
- (void)viewDidLoad {
[super viewDidLoad];
[scrollView setContentSize:CGSizeMake(540,620)];
composeTextView.delegate = self;
[composeTextView becomeFirstResponder]; $ IB

$ b}

如下:
textField to composeTextView
scrollView to scrollView
and the textField delegate to the file's owner。



再试一次建议。 / p>

I have a UITextView on a View that becomes the first responder.

When I embed the UITextView inside of a UIScrollView in Interface Builder the UITextView is no longer the first responder. I am not sure what has changed?

I would like the UITextView to become the first responder.

- (void)viewDidLoad {
    [super viewDidLoad];
    [scrollView setContentSize:CGSizeMake(540,620)];
    composeTextView.delegate = self;    
    [composeTextView becomeFirstResponder];
}

解决方案

This is my .h file:

#import <UIKit/UIKit.h>

@interface Untitled1ViewController : UIViewController <UITextFieldDelegate> {
    UIScrollView *scrollView;
    UITextField *composeTextView;
}

@property (nonatomic,retain) IBOutlet UIScrollView *scrollView;
@property (nonatomic,retain) IBOutlet UITextField *composeTextView;

@end

this is my .m file:

#import "Untitled1ViewController.h"

@implementation Untitled1ViewController
@synthesize scrollView;
@synthesize composeTextView;
- (void)viewDidLoad {
    [super viewDidLoad];
    [scrollView setContentSize:CGSizeMake(540,620)];
    composeTextView.delegate = self;    
    [composeTextView becomeFirstResponder];


}

in IB, i've connected the following: textField to composeTextView scrollView to scrollView and the textField delegate to the file's owner.

Try again and advise.

这篇关于UITextView里面的UIScrollView不是第一反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆