Adding subviews, yet I see nothing - iOS
I have a Controller 开发者_高级运维of which I have a few subviews. At a certain point in the code, I remove them, and then later on, I add them. Here is the code I use to add them:
[self.view addSubview:dateLabel];
[self.view addSubview:tableView];
Right after these lines, I print out:
NSLog(@"%@",[self.view subviews]);
and the output I get is:
"<UINavigationBar: 0x614a8f0; frame = (0 0; 320 48); layer = <CALayer: 0x6129ee0>>",
"<UILabel: 0x614d500; frame = (0 48; 320 25); text = 'Dec. 15, 2010 - Jan. 15, ...'; clipsToBounds = YES; userInteractionEnabled = NO; layer = <CALayer: 0x614d570>>",
"<UITableView: 0x507ee00; frame = (0 73; 320 390); clipsToBounds = YES; layer = <CALayer: 0x9f57930>; contentOffset: {0, 0}>"
However, the only thing I see on my screen is the navigation bar. Why is the label and the tableView not showing up even if it says here that it is a subView?
I have also tried to add the following code after adding the subviews:
[self.view bringSubviewToFront:tableView];
[self.view bringSubviewToFront:dateLabel];
but it still does not work.
Is your controller a UIViewController? Have you checked it has been presented correctly? For example with presentModalViewController:self ?
精彩评论