close

要按button 印出字串

首先, 分別完成印出字串, 和增加button的動作

然後

1) 開啟ViewController.m, 並在clickButtom:(id)sender之後, 增加下列程式

- (IBAction) clickButton:(id)sender{

if( [[myLabel text] length]==0 ){

   [myLabel setText:@"HelloWorld"];

}else{

  [myLabel setText:@""];

}

結果:

開機後, 會秀出button, 使用者點button後會秀出helloWorld的字串

再點一次, 就會清掉, 再點一次又會秀出字串, 使用者重複點button 就會

重複這動作

 

 

arrow
arrow
    全站熱搜

    hfchou 發表在 痞客邦 留言(0) 人氣()