I have this UIViewController which contains an UIScrollView. In the viewDidLoad method of the first controller, I create some UIViewControllers(defined through a NIB with an UILabel and an UIImageView inside,linking to IBOutlets done correctly), then I add them to the UIScrollView.
Problem is, I can see my views and scroll through them using the scroll view, but I seem to be unable to modify the text of the label and the content of the imageView using the methods [[UIViewController UILabel开发者_如何学Python] setText] or [[UIViewController UIImageView] setImage]
I know it sound like a stupid question, but I can't get past it. Any idea why?
Thank you guys.
You need to tag the Label and ImageView.
tag means assign a integer value to label and ImageView and you can access using the tag.
You can assign tags in xib.
Then you can access the view like this
[someController viewWithTag:(int)];
I think I have resolved my problem. I was trying to modify the views before adding them to the UIScrollView. If I call my methods after the [scrollview addSubView:myView], everything works fine.
精彩评论