1

我有一个 UITextView,我在视图 viewDidLoad 事件中以编程方式创建。

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.


    inputText = [[UITextView alloc] initWithFrame:CGRectMake(15, 90, 290, 150)];

    [inputText.layer setBackgroundColor: [[UIColor whiteColor] CGColor]];
    [inputText.layer setBorderColor: [[UIColor grayColor] CGColor]];
    [inputText.layer setBorderWidth: 3.0f];
    [inputText.layer setCornerRadius:8.0f];
    [inputText.layer setMasksToBounds:YES];
    [inputText setFont:[UIFont systemFontOfSize:15]];

    [self.view addSubview:inputText];

}

这很好用,第一次呈现视图,但第二次呈现时,UITextView 对触摸没有响应,键盘没有弹出。

这就是我指向视图的方式。

someotherView.m

-(IBAction)insertToTable:(id)sender {

       [self performSegueWithIdentifier:@"insertSegue" sender:self];
}

编辑 1

完整代码:

.h @interface ViewControllerInsert : UIViewController { UITextView *inputText; UISegmentedControl *experienceValue; }

- (IBAction)InsertAction:(id)sender;


@property (strong, nonatomic) IBOutlet UISegmentedControl *experienceValue;
@property (strong, nonatomic) IBOutlet UITextView *inputText;

@end

.m

除了我上面链接的代码,这就是全部

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    NSLog(@"touchesBegan:withEvent:");
    [self.view endEditing:YES];
    [super touchesBegan:touches withEvent:event];
}

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

@end

编辑 2

发现问题,这是由我使用的动画引起的?很奇怪,我使用的是垂直翻转,但是当我切换到默认值时,它工作得很好吗?

4

0 回答 0