@interface SomeViewController : UIViewController <UITextViewDelegate>
@property (retain, nonatomic) IBOutlet UIImageView *imageView;
@property (nonatomic, retain) UIImage *image;
@property (nonatomic, retain) IBOutlet UITextView *textView;
我需要textview(可编辑)在我的视图控制器。iphone。使UITextView,但不会使它可见
所以我设置的协议,
而且,1B对于文件的所有者了。 (我不知道,是没有必要?)
我的.m文件.... viewDidLoad中..
_textView = [[UITextView alloc]init];
[_textView setFrame:CGRectMake(8, 110, 304, 82)];
[_textView setFont:[UIFont boldSystemFontOfSize:12]];
_textView.editable = YES;
//[textView setText:@"hdgffgsfgsfgds"];// if uncommented, this actually visible...
[self.view insertSubview:_textView atIndex:2];
到目前为止,它的工作。但我想要这些方法运行...
- (void)textViewDidChange:(UITextView *)textView
{
if([_textView.text length] == 0)
{
_textView.text = @"Foobar placeholder";
_textView.textColor = [UIColor lightGrayColor];
_textView.tag = 0;
}
}
但生成后,我的textview仍然是空的。
我错了什么?
_textView.delegate = self;写这行。如果你不把你的控制放在.XIB文件中,则不需要IBOutlet。 – priyanka 2012-04-12 13:37:32