【发布时间】:2016-10-12 06:44:53
【问题描述】:
我有 uiviewController 作为主视图,然后我添加了名为“supporteview”的子视图。现在我在 supportview 上以编程方式添加按钮。 由于某种原因,按钮不可见,但是当我在主视图上加载按钮时,我可以看到按钮。
[self.view addSubview:self.supportview];
[self.view bringSubviewToFront:self.supportView];
[self.supportView addSubview:self.btn];
[self.supportView bringSubviewToFront:self.button];
我在 supportView 中添加了滑块,然后加载按钮。
【问题讨论】:
-
你是动态生成按钮还是在storyboard里面?
-
动态生成。
-
尝试更新按钮的框架。将 x 和 y 原点设置为按钮框架的 0。
-
看我以这种方式添加框架。浮动 xCordPerTimeStamp = SLIDER_WIDTH/self.slider.maximumValue;浮动 xcord = [playbyplay.GameTime floatValue] * 60; int finalx =(xCordPerTimeStamp *xcord) + startxoffset + XORIGIN; int finaly = 700; NSLog(@"final x is %d",finalx); if([playbyplay.Opponent isEqualToString:@"B"]) { finaly = 740; } NSLog(@"final x is %d and y%d",finalx,finaly); btn.frame = CGRectMake(finalx, finaly, 3, 8);
标签: ios uiview uibutton subview addsubview