2012-03-16 91 views
0

我在页脚中添加了UITextView的表格视图。一旦用户点击文本视图,我想让我的表格视图动画到顶部。这是用下面的一段代码完成的,但我必须将高度设置为负值。有没有其他的方式来做到这一点?使用增加高度将文本视图设置为顶部

- (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]; 
         }]; 

回答

0

也许这可以帮助你。

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

你可以调用这个方法:

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