搜尋此網誌

2012年9月9日 星期日

[xxxx]UILabe & UITableView&UITableViewCell問題集

1.怎么才能把UITableViewCell设为不可选中。
就像把按钮的enabled设为NO一样。全部鎖著cell.userInteractionEnabled = NO;
祇鎖一個cell.selectionStyle = UITableViewCellSelectionStyleNone;


2.如何讓uitableview固定
ANS:tableView.scrollEnabled

3. 如何換行

lblNeedSubscription = [[UILabel alloc] initWithFrame:frame];
[lblNeedSubscription setNumberOfLines:0];  // allows as many lines as needed
[lblNeedSubscription setText:@"To access content\ryou need to be a paid subscrib


表示不能換行且自動將自縮小
factLabel.numberOfLines = 1
factLabel.minimumFontSize = 8.;
factLabel.adjustsFontSizeToFitWidth = YES;
In this way your text's font size will reduce down to (for example) 8 trying to fit your text within the label.numberOfLines = 1 is mandatory.
For numberOfLines > 1 there is a method to figure out the size of final text through NSString's UIKit addition methods, for example:
CGSize lLabelSIze = [yourText sizeWithFont: factLabel.font forWidth:factLabel.frame.size.width lineBreakMode:factLabel.lineBreakMode];
After that you can just resize your label using resulting lLabelSIze, for example (assuming that you will change only label's height):
factLabel.frame = CGRectMake(factLabel.frame.origin.x, factLabel.frame.origin.y, factLabel.frame.size.width, lLabelSIze.height);

4.換顏色
label.textColor = [UIColor redColor];
5.給予不同cell不同高度

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{//判斷每個row所需要高度,判斷條件與產生cell一樣
    if (!videoList) {
        return 64;
    }else if(indexPath.row<[videoList count]){
        return 64;
    }else{//顯示更多高度降低
        return 48;
    }
}



沒有留言:

張貼留言