IOS 8 & Xcode 6:uialertview Cancel without callback Alertviewcancel:

Source: Internet
Author: User

When doing Uialertview cancel operation, find the delegate function Alertviewcancel: not be called, have to judge in Alertview:diddismisswithbuttonindex:.

1 @interfaceDateviewcontroller () <UIAlertViewDelegate>2@property (Weak, nonatomic) Iboutlet Uidatepicker *DatePicker;3 4 @end5 6 @implementationDateviewcontroller7 8- (void) Viewdidload {9 [Super Viewdidload];TenNSDate *now =[NSDate Date]; One [Self.datepicker Setdate:now animated:no]; A } -  -- (void) didreceivememorywarning { the [Super didreceivememorywarning]; -     //Dispose of any resources the can be recreated. - } -  +-(Ibaction) ButtonPress: (UIButton *) Sender { -NSDate *selecteddate =self.datePicker.date; +NSDateFormatter *fmt =[[NSDateFormatter alloc] init]; AFmt.dateformat =@"YYYY-MM-DD"; at  -NSString *string= [NSString stringWithFormat:@"You selecte%@", [FMT Stringfromdate:selecteddate]]; -Uialertview *view = [[Uialertview alloc] Initwithtitle:@"Date Picker" -Messagestring -                                                   Delegate: Self -Cancelbuttontitle:@"Cancel" inOtherbuttontitles:@"OK", nil]; - [view show]; to } +  -- (void) Alertviewcancel: (Uialertview *) Alertview { theNSLog (@"View canceled."); * } $ Panax Notoginseng- (void) Alertview: (Uialertview *) Alertview Diddismisswithbuttonindex: (Nsinteger) Buttonindex { -NSLog (@"Buttonindex =%zi", Buttonindex); the } +  A @end

The log output is as follows, the Cancel button is numbered 0, and the other button numbers increment in order of addition.

IOS 8 & Xcode 6:uialertview Cancel without callback Alertviewcancel:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.