iPhone – Move UiView up when display

I know this is a frequent problem, but I did not achieve this from the examples I found. I might make some simple mistakes.. (hopefully). I Trying to move the UIview to the bottom to hide the text field.

About my app, it has a tab bar controller and implements a standard UIView. When I add the code to move the display, there is nothing Response. I need to have a scroll view to use it, does it conflict with the tab controller or am I doing something wrong? Thank you

Tan

I wrote a small class on UIView, it Manage things that scroll temporarily, without the need to wrap the whole thing in a UIScrollView. My use of the verb “scroll” here may not be ideal, because it might make you think there is a scroll view, and there is no-we just animate the UIView( Or UIView subclass).

There are many magic numbers embedded here, these numbers fit my form and layout, and may not suit you, so I encourage you to adjust it to meet your specific Requirements.

UIView FormScroll.h:

#import 

@interface UIView (FormScroll )

-(void)scrollToY:(float)y;
-(void)scrollToView:(UIView *)view;
-(void)scrollElement:(UIView *) view toPoint:(float)y;

@end

UIView FormScroll.m:

#import "UIView+FormScroll .h"


@implementation UIView (FormScroll)


-(void)scrollToY:(float)y
{

[UIView beginAnimations:@"registerScroll" context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.4];
self.transform = CGAffineTransformMakeTranslation (0, y);
[UIVi ew commitAnimations];

}

-(void)scrollToView:(UIView *)view
{
CGRect theFrame = view.frame;
float y = theFrame.origin.y-15;
y -= (y/1.7);
[self scrollToY:-y];
}


-(void)scrollElement:(UIView *)view toPoint:(float)y
{
CGRect theFrame = view.frame;
float orig_y = theFrame.origin.y ;
float diff = y-orig_y;
if (diff <0) {
[self scrollToY:diff];
}
else {
[ self scrollToY:0];
}

}

@end

Import it into UIViewController, and then it’s fine

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[self.view scrollToView:textField];
}

-(void) textFieldDidEndEditing:(UITextField *)textField
{
[self.view scrollToY:0];
[textField resignFirstResponder];
}

…whatever. This category provides you with three good ways to adjust the position of the view.

I know this is a frequent problem, but I didn’t know from the examples I found Now this. I might make some simple mistakes.. (hopefully). I tried to move the UIview to the bottom to hide the text field.

About my app, it has a label Bar controller, and implements a standard UIView. When I add code to move the display, nothing happens. I need to have a scroll view to use it, does it conflict with the tab controller or am I doing something wrong? Thank you

Tan

I wrote a small class on UIView, which manages things that are temporarily scrolled, without the entire thing Wrapped into UIScrollView. My use of the verb “scroll” here may not be ideal, because it might make you think there is a scroll view, and there is no-we just animate the position of the UIView (or UIView subclass).

< /p>

There are many magic numbers embedded here, these numbers suit my form and layout, and may not suit yours, so I encourage you to adjust it to meet your specific needs.

UIView FormScroll. h:

#import 

@interface UIView (FormScroll)

-(void )scrollToY:(float)y;
-(void)scrollToView:(UIView *)view;
-(void)scrollElement:(UIView *)view toPoint:(float)y;

@end

UIView FormScroll.m:

#import "UIView+FormScroll.h"

< br />@implementation UIView (FormScroll)


-(void)scrollToY:(float)y
{

[UIView beginAnimations:@" registerScroll" context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.4];
self.transform = CGAffineTransformMake(0, y)Translation;
[UIView commitAnimations];

}

-(void)scroll ToView:(UIView *)view
{
CGRect theFrame = view.frame;
float y = theFrame.origin.y-15;
y -= (y/1.7) ;
[self scrollToY:-y];
}


-(void)scrollElement:(UIView *)view toPoint:(float)y
{
CGRect theFrame = view.frame;
float orig_y = theFrame.origin.y;
float diff = y-orig_y;
if (diff <0) {
[self scrollToY:diff];
}
else {
[self scrollToY:0];
}

}
< br />@end

Import it into UIViewController, and then it’s OK

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[self.view scrollToView:textField];
}

-(void) textFieldDidEndEditing:(UITextField *)textField
{
[ self.view scrollToY:0];
[textField resignFirstResponder];
}

…whatever. This category provides you with three good ways to adjust the view position.< /p>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1111 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.