2011-11-18 85 views
0

我試圖找出如何打開一個項目(例如:圖像)從一個視圖到另一個視圖。打開數據/圖像到另一個視圖

基本上用戶點擊我自定義爲圖片的按鈕。然後,它會將用戶帶到視圖中帶有該圖片的另一個視圖。

回答

0

子類視圖控制器,並作出新的init方法:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil image:(UIImage*)image 
    self = [super initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil]; 
    if (self) 
    { 
     [imageView setImage:image] 
    } 
    return self; 
} 

ImageView的是出口到一個UIImageView在筆尖

您可以使用init代替initWithNibName如果它適合你。

編輯:根據你的意見,你需要傳遞一個參考視圖控制器與圖像。

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(id)delegate 
    self = [super initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil]; 
    if (self) 
    { 
     viewDelegate = delegate; // you can use this to reference the view with the image 
    } 
    return self; 
} 
+0

如果我有說... 5次瀏覽。第五個視圖是所有圖像的位置。其他4個視圖只是包含文本,圖像等的普通窗口。我如何將所有這4個視圖鏈接到第5個視圖? – Nakioki

+0

真棒..我會試試這個。感謝您的幫助。如果我有更多問題,我會報告回答=] – Nakioki

+0

如果答案正確,請記住標記它。如果這不是你正在尋找的東西,但有幫助,請將它投票。如果你對每個問題都這樣做,Stackoverflow上的人將更願意幫助你。 – TigerCoding

相關問題