【问题标题】:HOw to change the textview size of one class from another class?如何从另一个类更改一个类的文本视图大小?
【发布时间】:2011-09-06 09:34:02
【问题描述】:

我正在开发一个应用程序。其中我创建了一个单元格。该单元格包含一个标签和 textview。在另一个类中,我在 tableview 中使用该单元格。当我们单击 textview 时,将出现键盘并且我正在尝试更改textview 大小。但它没有改变。所以请告诉我如何解决这个问题。我用于创建单元格的方法如下。

- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {

if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
    lbl=[[UILabel alloc]init];
    lbl.font = [UIFont boldSystemFontOfSize:17];
    txtview=[[UITextView alloc]init];
    txtview.editable=YES;
    //txtview.delegate=self;
    txtview.font=[UIFont italicSystemFontOfSize:13];
    txtview.backgroundColor=[UIColor clearColor];
    txtview.enablesReturnKeyAutomatically=YES;

    [self.contentView addSubview:lbl];
    [self.contentView addSubview:txtview];

}
return self;

}

- (void)layoutSubviews {

[super layoutSubviews];
lbl.frame=CGRectMake(7,10, 320, 20);

txtview.frame=CGRectMake(0,25, 320,339);

}

【问题讨论】:

    标签: iphone


    【解决方案1】:

    不要在 customcell 中设置 textview 的框架。而不是在类中创建单元格时设置框架

    cell.txtview.frame=CGRectMake(0,25, 320,339);
    

    【讨论】:

    • 您是否从 customcell 中删除了这一行(txtview.frame=CGRectMake(0,25, 320,339);)?
    • s。我删除了那个。我在创建单元格时提到了 etextview 大小。我在 textview 委托方法中更改了 textview 大小。但它不起作用
    • 你不能那样做,你为什么不在开始时分配实际大小。!
    猜你喜欢
    • 2013-09-17
    • 1970-01-01
    • 1970-01-01
    • 2018-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多