這是我的.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文件:
#import "Untitled1ViewController.h"
@implementation Untitled1ViewController
@synthesize scrollView;
@synthesize composeTextView;
- (void)viewDidLoad {
[super viewDidLoad];
[scrollView setContentSize:CGSizeMake(540,620)];
composeTextView.delegate = self;
[composeTextView becomeFirstResponder];
}
在IB中,我連接了以下內容: textField composeTextView scrollView滾動查看 和textField委託給文件的所有者。
重試並建議。
對我來說還是沒有運氣。你的composeTextView是否在你的scrollView中? – 2010-05-19 10:21:57
另外我使用的是UITextView而不是UITextField – 2010-05-19 10:25:00
謝謝!這段代碼很好用。我意識到我的UITextView沒有連接到IB。小錯誤,造成巨大的頭痛。 – 2010-05-19 11:21:21