2

Take a look at the following code, the problem is that the AlertView does not show up, even if I see in debug that the code is been executed.

Please advice.

Many thanks

Eran

    -(void)displayABC:(id)sender
{

    static int index = 0;
    NSString *path = [[NSBundle mainBundle] pathForResource:@"ABC" ofType:@"plist"];
    NSArray *ABCArray = [NSArray arrayWithContentsOfFile:path];
    if(index < [ABCArray count])
        [authButton setTitle:[ABCArray objectAtIndex:index] forState:UIControlStateNormal];
    index++;


    if (index > [ABCArray count]){

        UIAlertView *endOfABCAlertView = [[UIAlertView alloc] initWithTitle:@"XXX" message:@"XXX" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
        [self.view addSubview:endOfABCAlertView];

    }
}

I am using the latest Xcode 4.6.3 (is it a bug with the simulator? maybe ?)

4

3 回答 3

2

You aren't calling:

[endOfABCAlertView show];

If you can spare 3 minutes to look into header Displaying in Apple Documentation, you will find it.

于 2013-06-16T08:26:41.593 回答
1

[endOfABCAlertView show] is the way to show it. Do not add it as a subview.

Edit: The way to check what button was cancelled is by using the UIAlertViewDelegate protocol. See the docs for the specifics.

于 2013-06-16T08:25:58.003 回答
1

删除[self.view addSubview:endOfABCAlertView];并添加[endOfABCAlertView show];那会做..

于 2013-06-16T08:27:00.147 回答