2

UIAlertViewいずれかのボタン (1 と 2) を押した後も、これを維持しようとしています。

「+」ボタンまたは「-」ボタンをクリックすると、UILabelテキストの増分が表示され、UIAlertView.

これは私が現在使用しているものです:

#pragma Alert View Methods

-(void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated
{
        [self dismissWithClickedButtonIndex:buttonIndex animated:animated];

}

#pragma count functions
-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1 || buttonIndex == 2) {
        return;
    }
    else{

        [self dismissWithClickedButtonIndex:buttonIndex animated:YES];
    }
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1) {
        self.currentCountButtonCount++;
        [self.countAlert setMessage:[NSString stringWithFormat:@"%d",self.countButtonCount + 1]];

    }if (buttonIndex == 2) {
        self.currentCountButtonCount--;
        [self.countAlert setMessage:[NSString stringWithFormat:@"%d",self.countButtonCount - 1]];

    }
}

- (IBAction)countClick:(id)sender {


    // tallies and keeps current count number

    if (!self.currentCountButtonCount)
         self.currentCountButtonCount = 0;

   NSString *alertMessage = [NSString stringWithFormat:@"%d", self.countButtonCount];

    self.countAlert = [[UIAlertView alloc]initWithTitle:@"Count" message:alertMessage delegate:self cancelButtonTitle:@"end" otherButtonTitles:@"+",@"-", nil];

   [self.countAlert show];
}

私の最後の質問で、誰かがそれをカスタムにするように言った.

終了ボタンに触れるまでラベルが変更されている間、どうすればそれを維持できますか?

4

2 に答える 2

0

I don't want to rain in your parade, but if you think that an alert view is the best way to handle an increment/decrement of a variable, I would suggest you to reconsider your design.

UIAlertViews are meant for transient information and simplified decision making. A simple "Are you sure?" is the text-book example of an alert view usage.

From the user stand point, it's much more comforting being able to modify all the attributes in sliders or any other form of permanent input, and then, when sure, hit the confirm button with an alert view (or confirmation screen). Doing it in an Alert view is not only error prone, but counter-intuitive compared in the way that the rest of iOS works.

If you're having trouble on fitting another form of input in your application, please read on how to perform animations and reveal control as they are needed, hiding the input inside an UIAlertView is simply the easiest solution for you, but not the best for the user.

于 2013-07-15T05:27:43.263 に答える