2011-05-20 75 views
0

我想將文本視圖放在特定大小的圖像視圖上,但是當我從照片庫中加載圖像時,我的文本視圖會被寫入,而我無法在其上寫入圖像。我想,當我爲bi創建一個矩形框架時,圖庫中的圖像會覆蓋文本視圖。我該怎麼辦?textview從圖庫中被圖像覆蓋

答案:這是工作OCDE:

 
- (void)imagePickerController:(UIImagePickerController *)picker 
didFinishPickingMediaWithInfo:(NSDictionary *)info { 
    // set image 
    emailImage1 = [info objectForKey:UIImagePickerControllerOriginalImage]; 
    //bi.image = [info objectForKey:UIImagePickerControllerOriginalImage]; 

    image = [info objectForKey:UIImagePickerControllerOriginalImage]; 
    bi = [[UIImageView alloc ] initWithImage: image ]; 
    bi.frame = CGRectMake(20.0f, 100.0f,260.0f, 285.0f); 
    [self.view addSubview: bi]; 
    [self.view bringSubviewToFront:scroll]; 
    [[picker parentViewController] dismissModalViewControllerAnimated:YES]; 
    [picker release]; 
} 

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker 
    { 
    // release picker 
    [[picker parentViewController] dismissModalViewControllerAnimated:YES]; 
    [picker release]; 
} 


幫助PLZ

回答

0

語法是[self.view bringSubviewToFront:yourTextView];

+0

給出警告「uview不能響應bringubviewtofront」,它不選擇圖像窗體庫! – user720235 2011-05-23 08:24:01

1

嘿, 有磺酰基一行導致的問題。您添加bi作爲這樣的子視圖:

[self.view addSubview: bi ]; 

這是正確的。但從UIView的處理看這個:

添加後,此視圖將出現在任何其他子視圖之上。

試試下面的不是

[self.view insertSubview: bi belowSubview: YourTextView]; 

的指針您的TextView替換 'YourTextView'。比它應該工作。

Sandro Meier

+0

其不工作仍然面臨同樣的問題 – user720235 2011-05-23 08:14:28

+0

它必須工作。你能顯示你使用的代碼嗎? – 2011-05-23 08:23:14

+0

好的,我正在編輯我的代碼! – user720235 2011-05-23 09:47:07