對話框!彈出提示訊息(Alert)
跳出式對話框在每個平台語言都是很普遍的功能,在Mac上也不意外的提供這項功能,但依照外觀分為2種:
獨立視窗
執行後會以獨立視窗方式跳出顯示,顯示的位置大都在螢幕正中央,非程式視窗的中央。
程式內容:
//-----------start-----------
NSAlert *alert = [[NSAlert alloc] init];//右邊開始算起
[alert addButtonWithTitle:@"2012"];//右一
[alert addButtonWithTitle:@"2013"];//右二
[alert addButtonWithTitle:@"2014"];//右三
[alert addButtonWithTitle:@"2015"];//右四
[alert setMessageText:@"選擇您的答案"];//標頭
[alert setInformativeText:@"現在的年份?"];//內容
[alert setAlertStyle:NSCriticalAlertStyle];
NSInteger choice = [alert runModal];
NSLog(@"Dialog:%ld",(long)choice);
//------------end------------
(閱讀全文…)