- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
//以UIAlertView的title來決定判斷式
if ([alertView.title isEqualToString:@"Item A"]){
if (buttonIndex == 0) //若user於UIAlertView上click第一個按鈕
{
else if (buttonIndex == 1)//若user於UIAlertView上click第二個按鈕
{}
else if ([alertView.title isEqualToString:@"Item B"])
{
}
而後我們可以於任意地方建立UIAlertView
UIAlertView *alertView = [[UIAlertView alloc] init];
alertView.delegate = self;alertView.title = @"Item A";
alertView.alertViewStyle = UIAlertViewStylePlainTextInput; //可輸入文字的TextField
[alertView addButtonWithTitle:@"OK"];[alertView addButtonWithTitle:@"Cancel"];
[alertView show];
沒有留言:
張貼留言