최근에 또 다른 Iphone 문제가 발생했습니다. UIView 또는 UIScrollView가 프로그래밍 방식으로 만든 컨트롤에서 디스플레이를 새로 고치지 않습니다.
그것은 채팅, 그리고 모든 메시지를 내가 그들을 만드는거야 : 내가 melodramatically 일부 컨트롤을 만드는거야, 그들은 표시되지 않습니다, 그것은 새로 고침 방법의 일종이 필요합니다 .. 여기 내 레이아웃입니다 동적 인 이벤트가 나타나면 시작시 생성되는 내용이 나타나지만 나중에 작성하는 코드가 표시되지 않더라도 코드가 정상적으로 표시되지 않습니다.
컨트롤을 만드는 방법은 다음과 같습니다. 다음 함수를 호출) :
- (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;
[email protected]"green_bubble.png";
}
else {
left=5;
left_hour_button=240;
[email protected]"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);
}
누군가 디스플레이를 "새로 고침"하는 방법을 알려줄 수 있습니까?
이있는 ScrollView 클래스가
또한 내가 바닥에있는 ScrollView를 아래로 스크롤 할 것
을 유도하는에서 UIView의 나는 새 메시지를 추가 해요 때마다 내부 객체입니다. 내가 this post을 본 적이하지만이 작동하지 않거나 시뮬레이터에 이상한 행동한다 eighter 내가 아이폰을 소유하고 아직하지 않기 때문에 ... 는 장치에 그것을 시도하지 않은 ...
너무 많이 또는 전혀 스크롤하지 않지만 다른 탭으로 이동 한 다음 뒤로 스크롤하면 스크롤이 아래쪽으로 스크롤되고 심지어 내가 만든 프로그램 컨트롤이 표시됩니다. Wierd가 아닙니까?
그 문제는 내가 함수를 알리고 있었고 메인 스레드에서 호출되지 않았다는 것을 알았습니다. 그래서 나는 if와 같은 함수를 호출하여 같은 함수를 호출하여 발견했습니다 같은 params와 함께 .. 근무 – PartySoft