English 中文(简体)
电话
原标题:Alert view in iphone

我是新的应用。 我想设计一个警示,有2个县:OKCancel。 当用户触动OK,则我将打印以下信息:hello/code>。 当它们触及<代码>Cancel纽扣时, 页: 1

请帮助;我如何这样做?

问题回答

显示警示:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Do you want to say hello?"
                                                message:@"More info..."
                                               delegate:self
                                      cancelButtonTitle:@"Cancel"
                                      otherButtonTitles:@"Say Hello",nil];
[alert show];
[alert release];

a. 应对任何纽特:

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {
        NSLog(@"Cancel Tapped.");
    }
    else if (buttonIndex == 1) {
        NSLog(@"OK Tapped. Hello World!");
    }
}

For more information, see AlertView Reference

显示警示和下列警示:

UIAlertView *alert = [[UIAlertView alloc]
   initWithTitle:@"Make an informed choice"
   message:nil
   delegate:self
   cancelButtonTitle:@"Cancel"
   otherButtonTitles:@"OK", nil];
[alert show];

当警报被解除时,该代表将自行决定。 该代表必须执行《律师证明书》。

- (void)alertView:(UIAlertView *)alertView
   clickedButtonAtIndex:(NSInteger) buttonIndex{

   if (buttonIndex == 1) {
      // Do it!
   } else {
      // Cancel
   }
}

“enterography

<>目标C:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"My Alert"
            message:@"This is an action sheet." 
            preferredStyle:UIAlertControllerStyleAlert]; // 1
    UIAlertAction *firstAction = [UIAlertAction actionWithTitle:@"one"
            style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
                NSLog(@"You pressed button one");
            }]; // 2
    UIAlertAction *secondAction = [UIAlertAction actionWithTitle:@"two"
            style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
                NSLog(@"You pressed button two");
            }]; // 3

    [alert addAction:firstAction]; // 4
    [alert addAction:secondAction]; // 5

    [self presentViewController:alert animated:YES completion:nil]; // 6

<>Swift>

let alert = UIAlertController(title: "My Alert", message: "This is an action sheet.", preferredStyle: .Alert) // 1
    let firstAction = UIAlertAction(title: "one", style: .Default) { (alert: UIAlertAction!) -> Void in
        NSLog("You pressed button one")
    } // 2

    let secondAction = UIAlertAction(title: "two", style: .Default) { (alert: UIAlertAction!) -> Void in
        NSLog("You pressed button two")
    } // 3

    alert.addAction(firstAction) // 4
    alert.addAction(secondAction) // 5
    presentViewController(alert, animated: true, completion:nil) // 6

对于你可以使用的精减产出(有时,由于在器件上投射时,而不是在X条码上投射时出现ug缩,你可能会使用安全记录仪):

#define MY_ALERT(str) [[[UIAlertView alloc] initWithTitle:@"System Alert" message:str delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show]

之后,在你的法典中,你可以做到:

MY_ALERT(NSStringFromCGRect(someView.frame))




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。