2011-03-18 80 views
0

HII每一個,在iPhone應用程序清爽的UIView

在我的iPhone應用程序

是從FTP &加載,爲每個屏幕的頁腳,在viewDidLoad &上午配售下面的代碼來分配下載圖片(JPG格式)文件文件圖像可變

documentsDirectory = [documentsDirectory stringByAppendingPathComponent:@"XML"]; 
    documentsDirectory = [documentsDirectory stringByAppendingPathComponent:@"Extras"]; 
    imgLogo.image = [UIImage imageWithContentsOfFile:[documentsDirectory stringByAppendingPathComponent:@"logo.jpg"]]; 

但是當我們打開它會重新打開相同的屏幕2,3次後加載第一次屏幕圖像不顯示,,所以我需要刷新視圖,,,怎麼樣我可以那樣做嗎?任何一個可以幫助我,,,, thanx提前

+0

將代碼放入ViewDidAppear方法或設置[self.view setNeedsDisplay];(重繪您的視圖)刷新視圖。謝謝。 – Pugal 2011-03-18 05:13:37

回答

0

難道ü嘗試從蘋果文檔

[myView setNeedsDisplay]; 

報價:

By default, geometry changes to a view automatically redisplays the view without needing to invoke the drawRect: method. Therefore, you need to request that a view redraw only when the data or state used for drawing a view changes.In this case, send the view the setNeedsDisplay message. Any UIView objects marked as needing display are automatically redisplayed when the application returns to the run loop.

+0

雅我試過了,但它沒有工作 – Sowmya 2011-03-18 06:13:45

+0

然後我認爲該圖像尚不可用或在目錄中的時間點不存在。 – visakh7 2011-03-18 06:18:33

0

這可能是由於不完整的下載 請寫代碼來檢查該文件是否存在於該位置。 您也可以在一行中追加路徑 documentsDirectory = [documentsDirectory stringByAppendingPathComponent:@「XML/Extras/Logo.jpg」];

+0

雅文件正在下載到文件夾,,,但第一次圖像不顯示,但它會重新打開相同的屏幕時加載 – Sowmya 2011-03-18 06:16:45