簡體   English   中英

單擊按鈕時顯示圖像

[英]Displaying image when button clicked

我已經構建了此鍵盤,並且在圖片中您可以看到它,它是數字1,但我希望它變成數字2。

我以每個按鈕的標題作為標題來編寫,因此按鈕A的標題為A,當單擊按鈕時,它將在我在那些空框上方的大標簽中顯示A,這些空框為UIview。

有人知道我必須通過哪種方式才能使用此功能嗎? 還是因為我不知道

希望有人可以告訴我這里是圖片:

http://img213.imageshack.us/img213/4500/questionow.png

謝謝

編輯

這就是我現在得到的。

    IBOutlet UIImageView *imageview1;
    IBOutlet UIImageView *imageview2;
    IBOutlet UIImageView *imageview3;
    IBOutlet UIImageView *imageview4;
    IBOutlet UIImageView *imageview5;
    IBOutlet UIImageView *imageview6;
}

-(IBAction)showA;
-(IBAction)showB;
-(IBAction)showC;
-(IBAction)showD;
-(IBAction)showE;
-(IBAction)showF;
-(IBAction)showG;
-(IBAction)showH;
-(IBAction)showI;
-(IBAction)showJ;
-(IBAction)showK;
-(IBAction)showL;
-(IBAction)showM;
-(IBAction)showN;
-(IBAction)showO;
-(IBAction)showP;
-(IBAction)showQ;
-(IBAction)showR;
-(IBAction)showS;
-(IBAction)showT;
-(IBAction)showU;
-(IBAction)showV;
-(IBAction)showW;
-(IBAction)showX;
-(IBAction)showY;
-(IBAction)showZ;

.m

-(IBAction)showA {

UIImage *img = [UIImage imageNamed:@"A.png"];

[imageview1 setImage:img];

}

-(IBAction)showB {

UIImage *img = [UIImage imageNamed:@"B.png"];

[imageview1 setImage:img];  

}

等等。

UIImageview在空框中,第一個字母顯示得非常好

觀看了一些關於可變數組的教程,但仍不確定如何將其植入我的代碼中。

它是一個具有imagevie1、2、3、4、5、6的可變數組嗎?

希望你能再幫我一次

這更多的是關於組織您的想法,而不是實際的技術性事情。

1)檢查要填充多少個框,以便知道下一個要填充的框是什么。

2)有一種方法可以訪問每個盒子。

編輯1:構建數據源

這只是一種入門的方法:

1)首先創建一個NSMutableArray。

2)當您單擊任何按鈕時,使用NSMutableArray的大小,您可以自動知道圖像的放置位置:

myArray count = 0 => UIImageView 0 needs to be filled
myArray count = 1 => UIImageView 1 needs to be filled
myArray count = 2 => UIImageView 2 needs to be filled
myArray count = 3 => UIImageView 3 needs to be filled

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM