Iphone UIScrollVIew中的UIView不更新视图

Iphone UIScrollVIew中的UIView不更新视图,iphone,objective-c,ios,ipad,Iphone,Objective C,Ios,Ipad,我在UIScrollView中布置了一个UIView。有一个叫做更新UI的方法,它基本上更新UI。但是,在加载数据后,我需要向下滚动一点以查看呈现的UI。 例如,我尝试在LayoutSubView中隐藏UITableView,并在updateUI中取消隐藏它,但是我需要在UIScrollView上向下滚动一点,直到看到UITableView。为什么会这样?以下是我更新的UI代码: 当UIScrollView不滚动时,基本上会触发此updateUI代码。我有一个MyViewController,其

我在UIScrollView中布置了一个UIView。有一个叫做更新UI的方法,它基本上更新UI。但是,在加载数据后,我需要向下滚动一点以查看呈现的UI。 例如,我尝试在LayoutSubView中隐藏UITableView,并在updateUI中取消隐藏它,但是我需要在UIScrollView上向下滚动一点,直到看到UITableView。为什么会这样?以下是我更新的UI代码:

当UIScrollView不滚动时,基本上会触发此updateUI代码。我有一个MyViewController,其中有一个UIScrollView,它实现了UIScrollView委托,基本上当它不滚动时,它会委托回我的UIView,告诉你现在可以更新视图

- (void) updateUI
{
    self.isScrolling = NO;

    NSLog(@"UPDATE UI");

    AHMyImageData *object = self.object;

    if ([object isNotNull]){

    [self.tableView_ reloadData];

    if (![self.userProfileImage_.image isNotNull]){
        [self.userProfileImage_ setImageWithURL:[NSURL URLWithString:object.profilePicture_] andAnimate:YES];
    }

    if (![self.imageView_.image isNotNull]){
        NSString *url = [[object.image_ valueForKey:@"low_resolution"] valueForKey:@"url"];
        [self.imageView_ setImageWithURL:[NSURL URLWithString:url] andAnimate:YES];
    }

    if (object.userHasLiked){
        [self.likeButton_ setImage:[UIImage imageNamed:@"btn-like-down.png"] forState:UIControlStateNormal];
    } else {
        [self.likeButton_ setImage:[UIImage imageNamed:@"btn-like.png"] forState:UIControlStateNormal];
    }

    if ([object.text_ isNotNull]){
        NSMutableAttributedString * attributedString = [NSMutableAttributedString attributedStringWithString:object.text_];
        [attributedString setFont:[UIFont fontWithName:@"HelveticaNeue" size:15]];
        [self.titleLabel_ setAttributedText:attributedString];
        [self parseTagsInComment:object.text_];
    }

    NSMutableAttributedString * usernameAttributedString = [NSMutableAttributedString attributedStringWithString:object.username_];
    [usernameAttributedString setFont:[UIFont fontWithName:@"HelveticaNeue" size:14]];
    [usernameAttributedString setTextColor:[UIColor colorWithRed:86.0/255.0 green:134.0/255.0 blue:172.0/255.0 alpha:1.0] range:NSMakeRange(0, [object.username_ length])];
    [usernameAttributedString setTextBold:YES range:NSMakeRange(0, [object.username_ length])];

    [self.usernameLabel_ setAttributedText:usernameAttributedString];

    NSString * imageCreatorUsernameURL = [NSString stringWithFormat:@"userid://%@", object.userId_];
    [self.usernameLabel_ addCustomLink:[NSURL URLWithString:imageCreatorUsernameURL] inRange:NSMakeRange(0, [object.username_ length])];
    [self.usernameLabel_ setUnderlineLinks:NO];
    [self.usernameLabel_ setDelegate:self];

    [self.likesCountLabel_ setText:[NSString stringWithFormat:@"%d", object.likesCount]];
    [self.commentsCountLabel_ setText:[NSString stringWithFormat:@"%d", object.commentsCount]];

    if ([object.createdTime_ isNotNull]){
        [self.imageTimePostedLabel_ setText:[NSString timestampToString:object.createdTime_]];
    }


    [self setNeedsDisplay];
    [self setNeedsLayout];

    } else {
        NSLog(@"OBJECT IS NULL");
    }
}
试着打电话

[self.tableView_ reloadData];
// I think you need to call reloadData only
// AFTER you do all your fun updating stuff
[self setNeedsDisplay];
[self setNeedsLayout];

在你的功能的最后,而不是一开始。希望有帮助

听起来好像您正在从
UIScrollViewDelegate
方法调用
updateUIView
——如果这是真的,那么是哪一个?