2012-04-28 130 views
0

使用xcode 4.3.2不能滚动ScrollView

我是新来的,所以请保留任何答案。我试图遵循例子,但没有任何工作。我有一个包含文本框的页面。底部的那些被键盘隐藏起来。我想要的只是能够向上滚动,以便填写那些隐藏的字段。我附加了我的.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 

回答

1

您可以UIKeyboardDidShowNotification注册并设置滚动视图的contentInset使得底部插图等于键盘框架的高度(通知的userInfo的看到UIKeyboardFrameEndUserInfoKey键)。同样,当您收到UIKeyboardWillHideNotification时,只需将contentInset重置为UIEdgeInsetsZero即可。