如果验证警报,如何显示新的视图控制器? (目标c)

时间:2015-07-06 11:58:10

标签: ios objective-c uiviewcontroller alert

而不是按钮我想更改视图控制器,如果警报已经过验证,但我不知道该怎么做。我使用可可豆荚进行通知(只是因为设计很漂亮)。欢迎大家回答!

- (IBAction)changeTheme:(UIButton *)sender {

    // for changing view controller
    [UIView animateKeyframesWithDuration:1.0 delay:0 options:0 animations:^{
        changeTheme.transform = CGAffineTransformMakeScale(2, 2);
    } completion:^(BOOL finished) {

        // init alert with options
        SCLAlertView *changeThemeNotification = [[SCLAlertView alloc] init];

        // to sport
        [changeThemeNotification addButton:@"change to sport" validationBlock:^BOOL{
            BOOL passedValidation = true;
            return passedValidation;
        } actionBlock:^{

        }];
        // to food
        [changeThemeNotification addButton:@"change to food" validationBlock:^BOOL{
            BOOL passedValidation = true;
             return passedValidation;
        } actionBlock:^{
            [self.view setBackgroundColor:[UIColor blackColor]];
        }];

        // to animal
         [changeThemeNotification addButton:@"change to animal" validationBlock:^BOOL{
             BOOL passedValidation = true;
             return passedValidation;
         } actionBlock:^{
             [self.view setBackgroundColor:[UIColor greenColor]];
         }];

          // else (message & options)
        [changeThemeNotification showCustom:self image:nil color:[self.colorWheel randomColor] title:@"Test" subTitle:@"This is a test notification for the navigation." closeButtonTitle:@"stay" duration:0.0f];
        changeThemeNotification.hideAnimationType = SlideOutToBottom;
        changeThemeNotification.shouldDismissOnTapOutside = YES;
        changeThemeNotification.soundURL = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/url_to_sound.mp3", [[NSBundle mainBundle] resourcePath]]];

    }];
}

2 个答案:

答案 0 :(得分:0)

以下代码将有所帮助:

检查iOS版本:

frmMain fr = new frmMain();
fr.txtCustomer = dgv1FrmCustomer.SelectedRows[0].Cells[1].Value.ToString();
fr.Show();

显示警报视图:

frmProduct

还可以使用以下代码处理iOS< 8.0。

的“ok”按钮
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) 

答案 1 :(得分:0)

试试这个

  SCLAlertView *changeThemeNotification = [[SCLAlertView alloc] init];

  [changeThemeNotification addButton:@"change to sport" validationBlock:^BOOL{
        BOOL passedValidation = true;
        return passedValidation;
  } actionBlock:^{
      [self performSegueWithIdentifier:@"yourSegueName" sender:self];

  }];