2013-05-15 19 views
-1

我有視圖添加爲視圖中的子視圖在視圖中加載方法它工作正常,但在該方法的視圖的setFrame屬性然後如果我隱藏該視圖然後它不隱藏,我認爲由於setFrame屬性它不隱藏視圖。如何在應用setFrame屬性後隱藏任何UIView

 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)]; 
+0

哪裏是你的躲,視點編碼 –

+0

@Jdeveloper iPhone爲你THR? –

+0

爲什麼使用「initWithFrame」方法,然後使用「setFrame」方法?兩種方法都會導致相同的事情。 另外..請再粘貼一些代碼,以便我們可以更好地瞭解您到底在做什麼。 – Shailesh

回答

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

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