(上から見た図) と(ViewController
下から見た図) があります。ユーザーが編集を開始したときに、ビューの一番上に移動したい。ユーザーがすべてから編集を開始するときは問題ありませんが、ユーザーが最初に編集したいときに(キーボードを非表示にせずに)機能しません。は隠されていますが、フレームを変更しないでください。使用しようとしましたが、キーボードがポップアップしたときにのみ呼び出されます。UITextField
UITextView
UITextView
UITextView
UITextField
UITextView
UITextField
UITextView
UIKeyboardDidShowNotification
問題を再現するコード: ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITextViewDelegate>
@property (weak, nonatomic) IBOutlet UITextField *titleTF;
@property (weak, nonatomic) IBOutlet UITextView *bodyTV;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
-(void)textViewDidBeginEditing:(UITextView *)textView {
self.titleTF.hidden=YES;
CGRect newFrame=CGRectMake(20, 20, textView.frame.size.width, 100);
textView.frame=newFrame;
}
@end
アプリを実行して UITextView をクリックすると、アプリは次のよう になります 。
アプリを再起動します。最初に UITextField をクリックし、次に UITextView をクリックします。アプリは次のようになります: http://imageshack.us/photo/my-images/843/66433184.png UITextField は非表示ですが、UITextView はフレームを変更しませんでした。