2011-03-08 43 views

回答

4

这很简单。只需在单元格中添加没有背景色的UITextField即可。在您的cellForRowAtIndexPath方法中添加以下代码。

UITextField *inputText = [[UITextField alloc]initWithFrame:CGRectMake(10,10,280,22)]; 
inputText.textAlignment = UITextAlignmentLeft; 
inputText.backgroundColor = [UIColor clearColor]; 
inputText.placeHolder = @"Street"; 
[cell.contentView addSubview:inputText]; 
[inputText release]; 
+0

寻找MonoTouch解决方案。不过谢谢。 – 2011-03-08 03:47:53

+0

我能够通过您的答案推导出我的解决方案。谢谢。 – 2011-03-09 03:40:24

+4

@Brian David Berman:欢迎..但我建议你在这里发布你的答案(作为一个新的答案),以便它可以帮助其他人尝试做你所做的。 – EmptyStack 2011-03-09 03:43:58

1

该单元格是自定义单元格。它具有一些属性,一个可编辑的UITextField和一个用于空白内容的位置字符串。下面的代码是手动编写的,所以也许里面有一些bug。

@interface EditableCell : UITableViewCell { 
    UITextField *mTextField; 
} 
@property UITextField *textField; 

- (void)setPlaceHoldString:(NSString *)placeHolder; 
@end 

@implement EditableCell 
@synthesize textField = mTextField; 

- (void)setPlaceHoldString:(NSString *)placeHolder 
{ 
    self.textField.placeHolder = placeHolder; 
} 

- (UITextField *)textField 
{ 
    if (mTextField == nil) { 
     mTextField = [[UITextField alloc] init]; 

     // Configure this text field. 
     ... 

     [self addSubView:mTextField]; 
    } 

    return mTextField; 
} 

- (void)dealloc 
{ 
    self.textField = nil; 
    [super dealloc]; 
} 
@end 
+0

谢谢你的答案,但我一直在寻找MonoTouch版本。尽管如此,我会尝试从您的答案中获得我的解决方案。 – 2011-03-08 03:37:51

+0

哦,对不起,我看到标签有iPhone。 – AechoLiu 2011-03-08 04:30:32

相关问题