I m creating melodramatically some controls, and they don t appear, it needs some kind of a refresh method..
here s my layout:
it s a chat, and all those messages I m creating them dynamically as the event appears, what I m creating at startup, it does appear, but what I m creating afterward fails to show, even if the code is ok,
这里,我如何建立控制(通过称为以下职能):
- (void) AddNewMessage: (NSString *)msg date1:(NSString* ) date2 {
NSString *backimage =[NSString stringWithString:@""];
NSString *who =[NSString stringWithString:@"1"];
calculatedHeight=floor( msg.length / 40 )*20;
if (calculatedHeight<30) calculatedHeight=30;
if ([who isEqualToString:@"1"]) {
left=85;
left_hour_button=25;
backimage=@"green_bubble.png";
}
else {
left=5;
left_hour_button=240;
backimage=@"grey_bubble.png";
}
UIButton *button1 = [[UIButton alloc] initWithFrame:CGRectMake(left, lastcalculatedHeight-10, 230, calculatedHeight+10)];
[button1 setBackgroundImage:[[UIImage imageNamed:backimage] stretchableImageWithLeftCapWidth:9 topCapHeight:13] forState:UIControlStateDisabled];
[button1 setEnabled:FALSE];
[scrollView addSubview:button1];
[button1 release];
UIButton *buttonTime = [[UIButton alloc] initWithFrame:CGRectMake(left, lastcalculatedHeight+40, 50, 20)];
[buttonTime setBackgroundImage:[[UIImage imageNamed:@"hour_bubble.png"] stretchableImageWithLeftCapWidth:9 topCapHeight:13] forState:UIControlStateDisabled];
[buttonTime setFrame:CGRectMake(left_hour_button, lastcalculatedHeight+calculatedHeight-30, 55, 25)];
[buttonTime setTitle:date2 forState:UIControlStateDisabled];
[buttonTime setTitleColor:[UIColor blackColor] forState:UIControlStateDisabled];
buttonTime.titleLabel.font=[UIFont fontWithName:@"Helvetica" size:8.0];
buttonTime.titleLabel.lineBreakMode= UILineBreakModeWordWrap;
[buttonTime setEnabled:FALSE];
[scrollView addSubview:buttonTime];
[buttonTime release];
UILabel *labelMessage = [[UILabel alloc] initWithFrame:CGRectMake(left+5, lastcalculatedHeight-5, 220, calculatedHeight)];
[labelMessage setText:msg];
[labelMessage setFont:[UIFont fontWithName:@"Arial" size:12.0]];
[labelMessage setLineBreakMode:UILineBreakModeWordWrap];
[labelMessage setTextColor:[UIColor blackColor]];
[labelMessage setAdjustsFontSizeToFitWidth:NO];
[labelMessage setNumberOfLines:floor( msg.length / 40 )+2];
[labelMessage setBackgroundColor:[UIColor clearColor]];
[scrollView addSubview:labelMessage];
[labelMessage release];
lastcalculatedHeight+=calculatedHeight+20;
totalHeight+=calculatedHeight;
scrollView.contentSize = CGSizeMake(240, lastcalculatedHeight);
}
我如何“重新”展示?
上诉书是《Uiview》内的一个物体,从中得出。
我也想向下 bottom,每当我增加一个新信息时,我就将.。
I ve seen this post but either it doesn t work, or it acts weird on the simulator... haven t tried it on a device because I don t own an iPhone yet.
it scrolls too much or at all, but if I go to another tab, then switch back, the scroll is scrolled at the bottom, and it even shows the controls I ve created programmatically... Weird isn t it?