ScrollView blocking NavigationViewController

2019-09-14 23:52发布

问题:

I have a UIView with a UINavigation controller and several other Imageviews and a text filed inside it. On the Navigation bar there is a UIBarbutton item which pushes another ViewController.

When the text field in the Navigation Viewcontroller is tapped it brings up the keyboard causing the textfield to be blocked by the keyboard.I want to enable scroll view whenever the keyboard blocks the textfield.

A notification is sent to this method whenever the keyboard is invoked.

- (void)displayKeyboard {

scroll=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
scroll.contentSize=CGSizeMake(0, 500);
scroll.userInteractionEnabled=YES;
[self.view addSubview:scroll];

} 

I tried to programmatically add a scrollview onto the view but this causes the entire view to be blocked.I can see the scroller but it does not anything and i cant access the view anymore.

Am i doing something wrong ?

Is there any other way i can enable the scroll view whenever the keyboard appears so i can scoll the entire screen ?