ios uiscrollview addsubview not working
I am new at IOS development, but I have a problems with UIScrollView.
First of all, I have created Scroll View in storyboard and added
@property (retain, nonatomic) IBOutlet UIScrollView *mainScroll;
in view controller handler
In viewDidLoad method I have that code:
- (void)viewDidLoad
{
[super viewDidLoad];
self.mainScroll.contentSize = CGSizeMake(100.0,100.0); // Have to set
a size here related to your content.
// You should set these.
self.mainScroll.autoresizingMask = UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight;
self.mainScroll.minimumZoomScale = .5; // You will have to set some
values for these
self.mainScroll.maximumZoomScale = 2.0;
self.mainScroll.zoomScale = 1;
UIButton* b = [[UIButton alloc] init];
[b setBounds:CGRectMake(.0f,0.f,100.0,100.0)];
[self.mainScroll addSubview:b];
}
But nothing appears in the simulator. However if I add button on
storyboard in IB, button appears and I can scroll the view.
P.S. sorry for my language
No comments:
Post a Comment