无法更新我的视图的子视图

时间:2015-08-14 17:53:38

标签: ios objective-c iphone uiscrollview

无法更新我的观点的子视图

我正在使用一个带有scrollview的容器视图,我将其他一些viewcontroller的视图作为子视图添加到scrollview中。以下是将子视图添加到滚动视图的代码。

for (int i = 0; i < tags.count; i++) {
        CGRect frame;
        frame.origin.x = scrollView.frame.size.width * i;
        frame.origin.y = 0;
        RMKeyDetailViewController *det = [self.storyboard instantiateViewControllerWithIdentifier:@"RMKeyDetailViewController"];
        [self addChildViewController:det];
        frame.size = det.view.bounds.size;
        det.view.frame = frame;
        det.myTag = [tags objectAtIndex:i];
        [scrollView addSubview:det.view];
        [det didMoveToParentViewController:self];
    }

    pageControl.numberOfPages=tags.count;

    CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;

    CGFloat navbarheight = self.navigationController.navigationBar.frame.size.height;
    CGFloat totHeight = statusBarHeight+navbarheight;

    scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * tags.count, scrollView.frame.size.height-totHeight);

现在,在RMKeyDetailViewController中,我使用UIImagePickerController来选择图像并更新RMKeyDetailViewController中的imageview,如下所示,但是拾取的图像没有显示。

有人能建议我采用更好的方法来处理这种情况吗?

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    UIImage *image=[info objectForKey:UIImagePickerControllerOriginalImage];

    firstThumbImageView.image=image;

1 个答案:

答案 0 :(得分:0)

在将图片加载到名为 iv UIImageView时,您必须将 iv 添加到视图层次结构中。