سؤال

I have a UITableViewController and intend to add a subview to it when I click a button i.e. refresh button. My code is as follows:

//set up loading page
self.myLoadingPage = [[LoadingPageViewController alloc]init ];
self.myLoadingPage.view.frame = self.view.bounds;
self.myLoadingPage.view.hidden = NO;

[self.view addSubview:self.myLoadingPage.view];

My question is how can I set this subview to be in the current visible frame? especially for a UITableviewcontroller where I might click on the refresh button after scrolling down to the 100th cell, for this example, my subview will still be added right at the top of the table view (starting from cell 1). Is there any way to resolve this?

هل كانت مفيدة؟

المحلول

Just move the lines around so that you set the frame after you made it a subview

self.myLoadingPage = [[LoadingPageViewController alloc]init ];
self.myLoadingPage.view.hidden = NO;
[self.view addSubview:self.myLoadingPage.view];
self.myLoadingPage.view.frame = self.view.bounds;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top