我正在尝试通过iOS中的SCLAlertView创建一个按钮,因为我正在编写一个警告文本,并且生成按钮但我通常会获得由我在数组bubbleStringArray中创建的前一个按钮,我无法添加新的我正在使用另一个库BubbleButtonView。
-(void)viewDidLoad
{
bubbleStringArray=[[NSMutableArray alloc]initWithCapacity:40];
bubbleStringArray = [NSMutableArray arrayWithObjects:@"Hello", @"this", @"is", @"a", @"test", @"of", @"the", @"BubbleButtonView", @"class", @"Each", @"one", @"of", @"these", @"is", @"a", @"button",nil];
//[arraybuttons addObjectsFromArray:bubbleStringArray];
[bubbleStringArray addObjectsFromArray:apdel.sendArray];
//[bubbleStringArray addObjectsFromArray:addarray];
UIColor *textColor = [UIColor colorWithRed:255/255.0 green:47/255.0 blue:51/255.0 alpha:1.0];
UIColor *bgColor = [UIColor colorWithRed:254/255.0 green:255/255.0 blue:235/255.0 alpha:1.0];
//buttons generated
[bubbleView fillBubbleViewWithButtons:bubbleStringArray bgColor:bgColor textColor:textColor fontSize:14];
}
- (IBAction)addButtons:(id)sender {
SCLAlertView *alert = [[SCLAlertView alloc] init];
UITextField *textField = [alert addTextField:@"Enter your name"];
arraybuttons=[[NSMutableArray alloc]init];
//[arraybuttons addObjectsFromArray:apdel.bubbleStringArray];
[alert addButton:@"Ok" actionBlock:^(void) {
[arraybuttons addObject:[NSString stringWithFormat:@"%@",textField.text]];
[bubbleStringArray addObjectsFromArray:arraybuttons];
NSLog(@"%@",arraybuttons);
NSLog(@"%@",bubbleStringArray);
UIColor *textColor = [UIColor colorWithRed:255/255.0 green:47/255.0 blue:51/255.0 alpha:1.0];
UIColor *bgColor = [UIColor colorWithRed:254/255.0 green:255/255.0 blue:235/255.0 alpha:1.0];
//buttons generated
[bubbleView fillBubbleViewWithButtons:apdel.bubbleStringArray bgColor:bgColor textColor:textColor fontSize:14];
}];
[alert showEdit:self title:kInfoTitle subTitle:kSubtitle closeButtonTitle:kButtonTitle duration:0.0f];
}
答案 0 :(得分:0)
数组按钮未在操作块中分配。试试
[bubbleStringArray addObject:textfield.text];
而不是
[arraybuttons addObject:[NSString stringWithFormat:@"%@",textField.text]];
[bubbleStringArray addObjectsFromArray:arraybuttons];
PS什么是apdel.bubbleStringArray?