2012-11-29 3 views
0

UITableView 셀의 높이를 계산하는 데 다음 코드가 있습니다. 아이폰 OS 5.1.1 UITextView iOS 6에서 ContentSize.Height가 너무 높음

UIFont *textFont = [SettingsManagerUI defaultFontItalicWithSize:14]; 

    UIView *tempView = [[UIView alloc] init]; 

    UITextView *locationText = [[UITextView alloc] init]; 
    UITextView *moreInfoText = [[UITextView alloc] init]; 

    [tempView addSubview:locationText]; 
    [tempView addSubview:moreInfoText]; 

    [locationText setFont:textFont]; 
    [moreInfoText setFont:textFont]; 

    NSString *locationDetails = [MembersSavePartnerDetailsMoreInfoTableCell generateLocationTextWithPartner:partner inLocation:location]; 
    locationText.text = locationDetails; 

    NSString *moreInfo = partner ? partner.partnerDescription : location.partner.partnerDescription; 
    moreInfoText.text = moreInfo; 

    float locationTextHeight = locationText.contentSize.height; 
    float moreInfoTextHeight = moreInfoText.contentSize.height; 

locationTextHeight는 높이가 각각 1,420 및 2,482이다, (88) 및 iOS 6의 moreInfoTextHeight = 52이다.

iOS 6의 높이가 다른 이유는 무엇이며 어떻게 해결할 수 있습니까?

+0

는 난 그냥 문제가 무엇인지 깨달았다 생각 - 나는 UITextView는 프레임 개체를 초기화 할 필요가 있으므로 콘텐츠 크기에 사용할 너비를 알 수 있습니다. 나는 곧 그것을 시도 할 것이고, 해결책으로 입증되면 대답으로 게시 할 것이다. – Anthony

답변

2

이 문제는 프레임이있는 UITextView를 초기화하지 않아서 발생했습니다.

UITextView *locationText = [[UITextView alloc] initWithFrame:CGFrameMake(0,0,200,20)]; 
UITextView *moreInfoText = [[UITextView alloc] initWithFrame:CGFrameMake(0,0,200,20)]; 

는 아이폰 OS 6 전에 UITextView는 폭의 기본 프레임을 가지고 있어야합니다 0보다 큰

관련 문제