diff --git a/TTAlertView/TTAlertView.m b/TTAlertView/TTAlertView.m index 37773f6..f7467ca 100644 --- a/TTAlertView/TTAlertView.m +++ b/TTAlertView/TTAlertView.m @@ -292,12 +292,14 @@ - (void)setupButtons self.buttons = [NSMutableArray array]; - UIButton *cancelButton = [[UIButton alloc] init]; - [cancelButton setBackgroundColor:[UIColor blackColor]]; - [cancelButton addTarget:self action:@selector(cancelButtonAction:) forControlEvents:UIControlEventTouchUpInside]; - [cancelButton setTitle:self.cancelButtonTitle forState:UIControlStateNormal]; - [self.containerView addSubview:cancelButton]; - [self.buttons insertObject:cancelButton atIndex:_cancelButtonIndex]; + if (self.cancelButtonTitle) { + UIButton *cancelButton = [[UIButton alloc] init]; + [cancelButton setBackgroundColor:[UIColor blackColor]]; + [cancelButton addTarget:self action:@selector(cancelButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + [cancelButton setTitle:self.cancelButtonTitle forState:UIControlStateNormal]; + [self.containerView addSubview:cancelButton]; + [self.buttons insertObject:cancelButton atIndex:_cancelButtonIndex]; + } [self.otherButtonTitles enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [self addButtonWithTitle:(NSString *)obj];