通过增加高度将textview设置为顶部动画

时间:2012-03-16 06:01:12

标签: iphone objective-c ios cocoa-touch uiview

我有一个表格视图,页脚中添加了UITextView。一旦用户点击textview,我希望我的表格视图动画显示为顶部。这是通过下面的代码完成的,但我必须将高度设置为负数。还有其他方法吗?

- (void)textViewDidBeginEditing:(UITextView *)iTextView {
     [UIView animateWithDuration:0.4 
                             delay:0 
                            options:UIViewAnimationTransitionFlipFromLeft
                        animations:^{
                             self.myTextView.frame = CGRectMake(8, 4, 200, -160);
                             self.myTextView.text = @"test";
                             self.myTextView.font = [UIFont systemFontOfSize:14];
                             self.myTextView.textColor = [UIColor blackColor];
                         }        
                         completion:^(BOOL finished){
                             self.myLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, self.feedbackTextView.frame.size.height + kRunnerTopBottomMargin, kScreenWidth, 20.0f)] autorelease];
                             self.myLabel.backgroundColor = [UIColor clearColor];
                             self.myLabel.textColor = [UIColor darkGrayColor];
                             self.myLabel.text = @"default";
                             self.myLabel.textAlignment = UITextAlignmentCenter;
                             self.myLabel.font = [UIFont systemFontOfSize:12];
                             [self.view addSubview:self.myLabel];
                         }];

2 个答案:

答案 0 :(得分:1)

您可以调用此方法:

    [YourTableView setContentOffset:CGPointMake(0.0f, 0.0f) animated:YES];

答案 1 :(得分:0)

也许这可以帮到你。

- (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated;