我从github开始执行此项目。如何重新加载UIAlertView消息
它是自定义的AlertView。我明白它是如何工作的。修改为我的项目,像这样
Course1 - 一些产品的名称, '1' - 是它的量。当我输入正/负数量增加/减少时。但它只适用于我的变量(当我显示它时,我加载到这个AlertView上,它是1)。如何通过更改var(金额)重新加载此警报视图的消息。我无法理解。 在这里我的代码。
在我的课堂我叫警报查看该代码
BlockAlertView *alert = [BlockAlertView alertWithTitle: title message:ac.acCount];
[alert setCancelButtonWithTitle:@"-" block:nil];
[alert setDestructiveButtonWithTitle:@"+" block:^{
int u = [ac.acCount intValue];
u++;
ac.acCount = [NSString stringWithFormat:@"%d", u];
NSLog(@"%d", u);
}];
[alert addButtonWithTitle:@"Ok" block:^{
NSMutableArray *container = [[NSMutableArray alloc] init];
[container addObject:title];
[container addObject:price];
[container addObject:bId];
[container addObject:ac.acCount];
[container addObject:depid];
[[NSNotificationCenter defaultCenter] postNotificationName:@"MyNotification" object:container];
}];
[alert show];
显示方法只是绘制警报视图使用参数从alertWithTitle需要:标题消息:ac.acCount。下面是代码
+ (BlockAlertView *)alertWithTitle:(NSString *)title message:(NSString *)message
{
return [[[BlockAlertView alloc] initWithTitle:title message:message] autorelease];
}
这里
- (id)initWithTitle:(NSString *)title message:(NSString *)message
{
NSLog(@"title - %@ message - %@", title, message);
if ((self = [super init]))
{
UIWindow *parentView = [BlockBackground sharedInstance];
CGRect frame = parentView.bounds;
frame.origin.x = floorf((frame.size.width - background.size.width) * 0.5);
frame.size.width = background.size.width;
_view = [[UIView alloc] initWithFrame:frame];
_blocks = [[NSMutableArray alloc] init];
_height = kAlertViewBorder + 6;
if (title)
{
CGSize size = [title sizeWithFont:titleFont
constrainedToSize:CGSizeMake(frame.size.width-kAlertViewBorder*2, 1000)
lineBreakMode:UILineBreakModeWordWrap];
UILabel *labelView = [[UILabel alloc] initWithFrame:CGRectMake(kAlertViewBorder, _height, frame.size.width-kAlertViewBorder*2, size.height)];
labelView.font = titleFont;
labelView.numberOfLines = 0;
labelView.lineBreakMode = UILineBreakModeWordWrap;
labelView.textColor = kAlertViewTitleTextColor;
labelView.backgroundColor = [UIColor clearColor];
labelView.textAlignment = UITextAlignmentCenter;
labelView.shadowColor = kAlertViewTitleShadowColor;
labelView.shadowOffset = kAlertViewTitleShadowOffset;
labelView.text = title;
[_view addSubview:labelView];
[labelView release];
_height += size.height + kAlertViewBorder;
}
if (message)
{
CGSize size = [message sizeWithFont:messageFont
constrainedToSize:CGSizeMake(frame.size.width-kAlertViewBorder*2, 1000)
lineBreakMode:UILineBreakModeWordWrap];
UILabel *labelView = [[UILabel alloc] initWithFrame:CGRectMake(kAlertViewBorder, _height, frame.size.width-kAlertViewBorder*2, size.height)];
labelView.font = messageFont;
labelView.numberOfLines = 0;
labelView.lineBreakMode = UILineBreakModeWordWrap;
labelView.textColor = kAlertViewMessageTextColor;
labelView.backgroundColor = [UIColor clearColor];
labelView.textAlignment = UITextAlignmentCenter;
labelView.shadowColor = kAlertViewMessageShadowColor;
labelView.shadowOffset = kAlertViewMessageShadowOffset;
labelView.text = message;
[_view addSubview:labelView];
[labelView release];
_height += size.height + kAlertViewBorder;
}
_vignetteBackground = NO;
}
return self;
}
我试图用这样的
-(void)reloadAlertView: (NSString *) title: (NSString *) message{
[self initWithTitle:title message:message];
}
,并从我的课,把这个地方我显示警报视图。
[alert reloadAlertView: title: newMessage];
你可以发表一些你在这里尝试的代码吗?顺便说一句你的问题不是很清楚,你究竟想要什么。清楚地说明plz – mAc 2013-02-25 12:19:46
只需显示您的代码,绝对可以按照您的要求进行自定义。 – 2013-02-25 12:21:03
请注意,您不是使用'UIAlertView',而是使用不带'UIAlertView'子类的替代品 - >,因此您的主题和问题文本至少是误导性的。 – Till 2013-02-25 12:38:15