autolayout uiscrollview problem
- Get link
- X
- Other Apps
hi @ all, have little problem autolayout, have custom uiview view, 1 of view called view_a, need add n scrollview in same position, 1 upon other, scrollview have content view inside n subview, write code:
the problem scrollview & scrollviewcontanto have frame = 0, inside isn't clickable, mistake?code:- (void) initproducts { (int i=0; i<_collezioni.count;i++) { page *collezione = [_collezioniobjectatindex:i]; uiscrollview *scrollview = [[uiscrollviewalloc] init]; [scrollview settag:100 + collezione._id]; [_productsviewaddsubview:scrollview]; uiview *scrollviewcontent = [[uiviewalloc] init]; [scrollviewcontent setbackgroundcolor:[uicolorredcolor]]; [scrollview addsubview:scrollviewcontent]; scrollview.translatesautoresizingmaskintoconstraints = no; scrollviewcontent.translatesautoresizingmaskintoconstraints = no; id views = @{ @"scrollview": scrollview, @"scrollviewcontent": scrollviewcontent }; [_productsviewaddconstraints:[nslayoutconstraintconstraintswithvisualformat: @"h:|[scrollview]|"options:0metrics:nilviews:views]]; [_productsviewaddconstraints:[nslayoutconstraintconstraintswithvisualformat: @"v:|[scrollview]|"options:0metrics:nilviews:views]]; [_productsviewaddconstraints:[nslayoutconstraintconstraintswithvisualformat: @"h:|[scrollviewcontent]|"options:0metrics:nilviews:views]]; [_productsviewaddconstraints:[nslayoutconstraintconstraintswithvisualformat: @"v:|[scrollviewcontent]|"options:0metrics:nilviews:views]]; nsmutabledictionary *dictprodotti = [nskeyedunarchiverunarchiveobjectwithdata:[_userobjectforkey:key_prodotti]]; nsmutablearray *prodotti = [dictprodotti objectforkey:[nsstringstringwithformat: @"%d",collezione._id]]; int count = 0; (page *page in prodotti) { singleproduct *singleproduct = [[singleproductalloc] initwithframe:cgrectmake(_productsview.frame.size.height * count, 0, _productsview.frame.size.height, _productsview.frame.size.height - 40)]; [singleproduct settranslatesautoresizingmaskintoconstraints:yes]; [singleproduct settag:100 + page._id]; [singleproduct setprodotto:page]; [singleproduct setdelegate:self]; [scrollviewcontent addsubview:singleproduct]; count++; } [scrollviewcontent setframe:cgrectmake(0, 0, _productsview.frame.size.height, _productsview.frame.size.height)]; [scrollview setcontentsize:cgsizemake(prodotti.count * _productsview.frame.size.height, _productsview.frame.size.height)]; } }
in ios top view current view or 1 can click on.
why need views stacked this?
time have done such thing build single view controller contained 2 views. 1 of views hidden (by view on top of it) unless user selects item bar. did make top view hidden.
code use simple, "self.someview.hidden = yes;"
when user done underlying view simple unhide top view, "self.someview.hidden = no; touch response returns view.
Forums iPhone, iPad, and iPod Touch iOS Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
- Get link
- X
- Other Apps
Comments
Post a Comment