From 955fc910c8e17fd708590a10d407ec6bddabfde5 Mon Sep 17 00:00:00 2001 From: Simon Holroyd Date: Fri, 10 May 2013 11:00:36 -0400 Subject: [PATCH] bugfixing empty cancel button title --- TTAlertView/TTAlertView.m | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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];