-1

我有在视图中添加为子视图的视图在视图中确实加载方法它工作正常但是在方法中该视图的 setFrame 属性之后,如果我隐藏该视图然后它不会隐藏,我认为由于 setFrame 属性它没有隐藏视图.

      NineView=[[UIView alloc] initWithFrame:CGRectMake(570,300,50,-height9)];

  NineView.backgroundColor=[UIColor colorWithRed:(102/255.f) green:(107/255.f) blue:(40/255.f) alpha:1];

  [self.view addSubview:NineView];

在 setFrame 之后,如果我隐藏此视图,则它不会隐藏它

            [NineView setFrame:CGRectMake(570,300,50,-height9)];
4

2 回答 2

0

您可以在方法之后隐藏setFrame并且您正在做一件事是错误的,您X coordinate超出了 320 因此您看不到您的视图,因为它超出了屏幕范围。并在你的方法中写下这段代码,你想在哪里隐藏这个视图。如果你不能隐藏它意味着你在你的代码中做错了什么。

[NineView setHidden:YES];

注意:在 iPhone 4

   X coordinate should be x >= 0 and  x <= 320
   Y coordinate should be y >= 0 and  y <= 480

在 iPhone 5 中

   X coordinate should be x >= 0 and  x <= 320
   Y coordinate should be y >= 0 and  y <= 568
于 2013-05-15T12:04:36.020 回答
0
NineView=[[UIView alloc] initWithFrame:CGRectMake(570,300,50,-height9)];
NineView.backgroundColor=[UIColor colorWithRed:(102/255.f) green:(107/255.f) blue:(40/255.f) alpha:1];
[self.view addSubview:NineView];
[NineView setHidden:YES];

应该隐藏你的观点就好了。

编辑:此外,您的视图的 X 坐标会将您的视图置于屏幕边界之外。它应该小于 320。因为 iPhone 的最大宽度是 320,高度是 480。对于 iPhone5,高度是 568。

于 2013-05-15T12:32:19.703 回答