0

使用 xcode 4.3.2

我是新手,所以请保持任何答案简单。我试图遵循示例,但没有任何效果。我有一个带有文本字段的页面。底部的被键盘隐藏。我想要的只是能够向上滚动,以便我可以填写那些隐藏的字段。我附上了我的 .m 文件。

#import "Engine Editor.h"

@interface Engine_Editor 

@end

@implementation Engine_Editor
@synthesize Enginescroll;
@synthesize MainEngineField;
@synthesize MainSerialField;
@synthesize MainServiceField;
@synthesize AuxEngineField;
@synthesize AuxSerialField;
@synthesize AuxServiceField;
@synthesize BLANK;
@synthesize ReturnEngine;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}

 - (void)viewDidLoad
  {
 self.MainEngineField.text=((ViewController *)self.presentingViewController).MainEngineLabel.text;
 self.MainSerialField.text=((ViewController *)self.presentingViewController).MainSerialLabel.text;
 self.MainServiceField.text=((ViewController *)self.presentingViewController).MainServiceLabel.text;
 self.AuxEngineField.text=((ViewController *)self.presentingViewController).AuxEngineLabel.text;
 self.AuxSerialField.text=((ViewController *)self.presentingViewController).AuxSerialLabel.text; 
 self.AuxServiceField.text=((ViewController *)self.presentingViewController).AuxServiceLabel.text;



[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
[self setEnginescroll:nil];
[self setMainEngineField:nil];
[self setMainSerialField:nil];
[self setMainServiceField:nil];
[self setAuxEngineField:nil];
[self setAuxSerialField:nil];
[self setAuxServiceField:nil];
[self setReturnEngine:nil];
[self setBLANK:nil];

[Enginescroll setScrollEnabled:YES];
[Enginescroll setShowsVerticalScrollIndicator:YES];
[Enginescroll setFrame:CGRectMake(0, 55, 320, 320)];
[Enginescroll setContentSize:CGSizeMake(320, 600)];



[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)DismissEditor:(id)sender {

((ViewController *)self.presentingViewController).MainEngineLabel.text=self.MainEngineField.text;
[self dismissViewControllerAnimated:YES completion:Nil];
((ViewController *)self.presentingViewController).MainSerialLabel.text=self.MainSerialField.text;
[self dismissViewControllerAnimated:YES completion:Nil];
((ViewController *)self.presentingViewController).MainServiceLabel.text=self.MainServiceField.text;
[self dismissViewControllerAnimated:YES completion:Nil];
((ViewController *)self.presentingViewController).AuxEngineLabel.text=self.AuxEngineField.text;
[self dismissViewControllerAnimated:YES completion:Nil];
((ViewController *)self.presentingViewController).AuxSerialLabel.text=self.AuxSerialField.text;
[self dismissViewControllerAnimated:YES completion:Nil];
((ViewController *)self.presentingViewController).AuxServiceLabel.text=self.AuxServiceField.text;
[self dismissViewControllerAnimated:YES completion:Nil];

}

- (IBAction)HideKeyBoard:(id)sender {
}
@end
4

1 回答 1

1

您可以注册UIKeyboardDidShowNotification并设置滚动视图contentInset,以便底部插图等于键盘框架的高度(请参阅UIKeyboardFrameEndUserInfoKey通知的键userInfo)。同样,当您收到时,UIKeyboardWillHideNotification只需将其重置contentInsetUIEdgeInsetsZero.

于 2012-04-28T10:37:17.673 回答