ios - TextField not being added to ScrollView -
when input following code, textfields added not being displayed in scrollview:
.h
@interface firstviewcontroller : uiviewcontroller <uiscrollviewdelegate> @property (strong, nonatomic) iboutlet uiscrollview *scrollview; @property (strong, nonatomic) uitextfield *firstfield; @property (strong, nonatomic) uitextfield *secondfield; @property (strong, nonatomic) uitextfield *thirdfield;
.m (viewdidload)
self.firstfield.placeholder = @"first"; self.firstfield.textalignment = nstextalignmentcenter; self.firstfield.font = [uifont fontwithname:@"helvetica neue light" size:50.0]; self.secondfield.placeholder = @"second"; self.secondfield.textalignment = nstextalignmentcenter; self.secondfield.font = [uifont fontwithname:@"helvetica neue light" size:50.0]; self.thirdfield.placeholder = @"third"; self.thirdfield.textalignment = nstextalignmentcenter; self.thirdfield.font = [uifont fontwithname:@"helvetica neue light" size:50.0]; [self.scrollview addsubview:self.firstfield]; [self.firstfield autopinedgestosuperviewedgeswithinsets:uiedgeinsetszero excludingedge:aledgeright]; [self.firstfield automatchdimension:aldimensionwidth todimension:aldimensionwidth ofview:self.scrollview]; [self.firstfield automatchdimension:aldimensionheight todimension:aldimensionheight ofview:self.scrollview]; [self.scrollview addsubview:self.secondfield]; [self.secondfield autopinedge:aledgeleft toedge:aledgeright ofview:self.firstfield]; [self.secondfield automatchdimension:aldimensionwidth todimension:aldimensionwidth ofview:self.scrollview]; [self.secondfield automatchdimension:aldimensionheight todimension:aldimensionheight ofview:self.scrollview]; [self.scrollview addsubview:self.thirdfield]; [self.thirdfield autopinedge:aledgeleft toedge:aledgeright ofview:self.secondfield]; [self.thirdfield autopinedgestosuperviewedgeswithinsets:uiedgeinsetszero excludingedge:aledgeleft]; [self.thirdfield automatchdimension:aldimensionwidth todimension:aldimensionwidth ofview:self.scrollview]; [self.thirdfield automatchdimension:aldimensionheight todimension:aldimensionheight ofview:self.scrollview]; self.automaticallyadjustsscrollviewinsets = no;
i have self.scrollview within scrollview way (in pageviewcontroller). using purelayout position text fields, , i'm pretty sure way did correct. there i'm missing?
yes missing code,if wan't add uitextfield programmatically must set size , position on you're view, that:
self.firstfield.frame = cgrectmake(10, 200, 300, 40);
i hope you.
Comments
Post a Comment