ios - UIScrollView not showing uilabel text -


i developing simple app. in there text displaying inside uiscrollview , pagecontrol app isn't giving error isn't showing text in scrollview. here code.

in .h

@property (nonatomic, strong) iboutlet uiscrollview *scrollview; @property (nonatomic, strong) iboutlet uipagecontrol *pagecontrol; 

in .m

@interface dashboardviewcontroller () @property (nonatomic, strong) nsarray *pagetext; @property (nonatomic, strong) nsmutablearray *pageviews;  - (void)loadvisiblepages; - (void)loadpage:(nsinteger)page; - (void)purgepage:(nsinteger)page; @end  @implementation dashboardviewcontroller @synthesize scrollview = _scrollview; @synthesize pagecontrol = _pagecontrol;  @synthesize pagetext = _pagetext; @synthesize pageviews = _pageviews; #pragma mark -  - (void)loadvisiblepages {     // first, determine page visible     cgfloat pagewidth = self.scrollview.frame.size.width;     nsinteger page = (nsinteger)floor((self.scrollview.contentoffset.x * 2.0f + pagewidth) / (pagewidth * 2.0f));      // update page control     self.pagecontrol.currentpage = page;      // work out pages want load     nsinteger firstpage = page - 1;     nsinteger lastpage = page + 1;      // purge before first page     (nsinteger i=0; i<firstpage; i++) {         [self purgepage:i];     }     (nsinteger i=firstpage; i<=lastpage; i++) {         [self loadpage:i];     }     (nsinteger i=lastpage+1; i<self.pagetext.count; i++) {         [self purgepage:i];     } }  - (void)loadpage:(nsinteger)page {     if (page < 0 || page >= self.pagetext.count) {         // if it's outside range of have display, nothing         return;     }      // load individual page, first checking if you've loaded     uiview *pageview = [self.pageviews objectatindex:page];     if ((nsnull*)pageview == [nsnull null]) {         cgrect frame = self.scrollview.bounds;         frame.origin.x = frame.size.width * page;         frame.origin.y = 0.0f;         frame = cgrectinset(frame, 10.0f, 0.0f);          uilabel *newpagetext = [[uilabel alloc] init];         newpagetext.textcolor = [uicolor whitecolor];         newpagetext.contentmode = uiviewcontentmodescaleaspectfit;         newpagetext.frame = frame;         [self.scrollview addsubview:newpagetext];         [self.pageviews replaceobjectatindex:page withobject:newpagetext];     } }  - (void)purgepage:(nsinteger)page {     if (page < 0 || page >= self.pagetext.count) {         // if it's outside range of have display, nothing         return;     }      // remove page scroll view , reset container array     uiview *pageview = [self.pageviews objectatindex:page];     if ((nsnull*)pageview != [nsnull null]) {         [pageview removefromsuperview];         [self.pageviews replaceobjectatindex:page withobject:[nsnull null]];     } }  - (void)scrollviewdidscroll:(uiscrollview *)scrollview {     // load pages on screen     [self loadvisiblepages]; } - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil {     self = [super initwithnibname:nibnameornil bundle:nibbundleornil];     if (self) {         // custom initialization     }     return self; } - (void)viewwillappear:(bool)animated {             self.edgesforextendedlayout = uirectedgenone;     // set content size of scroll view     cgsize pagesscrollviewsize = self.scrollview.frame.size;     self.scrollview.contentsize = cgsizemake(pagesscrollviewsize.width * self.pagetext.count, pagesscrollviewsize.height);     // load initial set of pages on screen     [self loadvisiblepages];     [super viewwillappear:animated]; } 

here viewdidload

- (void)viewdidload {      self.pagetext = @[@"lorem ipsum dolor sit amet, consectetur adipiscing elit, sed eiusmod tempor incididunt ut labore et dolore magna aliqua.", @"ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", @"duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."];     nsinteger pagecount = self.pagetext.count;     // set page control     self.pagecontrol.currentpage = 0;     self.pagecontrol.numberofpages = pagecount;     // set array hold views each page     self.pageviews = [[nsmutablearray alloc] init];     (nsinteger = 0; < pagecount; ++i) {         [self.pageviews addobject:[nsnull null]];     } [super viewdidload];     // additional setup after loading view. } 

here screenshot enter image description here


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -