どのように私はテキストボックスとボタンでUITableViewCellを作成できますか?このコードで試しましたが、テキストボックスは表示されませんが、ボタンは表示されません。テキストボックスとボタンでUITableViewCellを作成しますか?
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierWithTextBox];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifierWithTextBox] autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
CGRect textRect = CGRectMake(10, 20, 500, 31);
UITextField *myfield = [[UITextField alloc]initWithFrame:textRect];
myfield.borderStyle = UITextBorderStyleRoundedRect;
myfield.font = [UIFont systemFontOfSize:22.0];
myfield.adjustsFontSizeToFitWidth = YES;
myfield.minimumFontSize = 2.0;
myfield.clearButtonMode = UITextFieldViewModeWhileEditing;
myfield.keyboardType = UIKeyboardTypeDefault;
myfield.autocorrectionType= UITextAutocorrectionTypeNo;
myfield.autocapitalizationType=UITextAutocapitalizationTypeNone;
myfield.returnKeyType=UIReturnKeyDone;
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
doneButton.frame = CGRectMake(520, 10, 30, 30); // position in the parent view and set the size of the button
[doneButton setTitle:@"Registry now" forState:UIControlStateNormal];
// add targets and actions
[doneButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
// add to a view
[cell.contentView addSubview: myfield];
[cell.contentView addSubview: doneButton];
[doneButton release];
[myfield release];
}
忘れてしまった!私はipadをコーディングしています。それについて申し訳ありません! – 9891541