對馬蒂亞斯的回答繼當前圖像最簡單的做法「沒有必要做這個,只是通過UIImage的實例,」這是解決方案對我來說,與同胞newbs具體代碼:
Calling .m:
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
//Create an instance of the destination controller
dmImageZoom *dmz = (dmImageZoom *)[segue destinationViewController];
//Get the tapped button (the image was in a button) into a button object
UIButton *btnImg= sender;
//Get the button's image object
UIImage *img=btnImg.currentImage;
//Pass the image object to the destination controller's instance variable
dmz.imgPassed=img;
Called .h:
@interface dmImageZoom : UIViewController {
//Instance variable
UIImage *imgPassed;
}
//Property for the object that presents the image
@property (strong, nonatomic) IBOutlet UIImageView *imgView;
//Property that enables it to be assigned a value
@property (strong, nonatomic) IBOutlet UIImage *imgPassed;
Called .m:
- (void)viewDidLoad
{
...
imgView.contentMode = UIViewContentModeScaleAspectFit;
//Assign the image to view object
imgView.image=imgPassed;
我有幾個按鈕,我想,當我得到的圖像名稱按一個按鈕,切換到另一個視圖控制器並加載該圖像的名稱。 – karse23 2011-02-14 09:26:34