我有一个scrollview
。我在同一行放置了一个textfield
和一个按钮。我希望当用户在textbox
中输入URL
并点击button
时,URL
应该被添加动态地创建textview
而不是textbox
和button
。 (我正在使用textview
,因为它会自动检测URL
并作为链接显示)。 我已经尝试下面的代码,但它不工作:动态添加textview点击按钮中的ios目标c
- (IBAction)addLinkClicked:(id)sender {
NSLog(@"Add Link button clicked");
UITextView *linkTextView = [[UITextView alloc] init];
linkTextView.text = @"http://google.com";
linkTextView.layer.cornerRadius = 5.0;
[self.scrollView addSubview:linkTextView];
}
2.
- (IBAction)addLinkClicked:(id)sender {
NSLog(@"Add Link button clicked");
UITextView *linkTextView = [[UITextView alloc] init];
linkTextView.text = @"http://google.com";
linkTextView.layer.cornerRadius = 5.0;
[self.scrollView insertSubview:linkTextView atIndex:[self.scrollView.subviews count]];
}
请帮我解决我的问题。
设置UITextView框架 – Mutawe