![](/img/trans.png)
[英]Can I implement “select” and “copy” on UILabel when it has a long press just as UITextField (UITextView、UIWebView), and how?
[英]How can I implement a “double” UITextField?
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 2; }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } if(indexPath.row == 0) { cell.textLabel.text = @"Username"; UITextField *field = [[[UITextField alloc] initWithFrame: CGRectMake(120, 10, 180, 30)] autorelease]; [cell addSubview:field]; } else if(indexPath.row == 1) { cell.textLabel.text = @"Password"; UITextField *field = [[[UITextField alloc] initWithFrame: CGRectMake(120, 10, 180, 30)] autorelease]; field.secureTextEntry = YES; [cell addSubview:field]; } return cell; }
- (NSString *)tableView: (UITableView *)tableView titleForHeaderInSection: (NSInteger)section { return @"Account"; }
- (NSString *)tableView: (UITableView *)tableView titleForFooterInSection: (NSInteger)section { return @"If you don't have a twitter account, go to twitter.com to sign up."; }
您需要将UITextField对象放置在表中以实现此效果。 有关更多详细信息,请参见UITableView: http : //developer.apple.com/iphone/library/DOCUMENTATION/UIKit/Reference/UITableView_Class/Reference/Reference.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.