简体   繁体   中英

Objective C: How to set the subview display in the current visible frame? (UITableView)

I have a UITableViewController and intend to add a subview to it when I click a button ie 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM