您可以在同樣的方法也做了,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==2)
{
//Create a UIButton
//Assign target
//Add the button as a subview to cell.contentView
}
else
{
//Add the textFields
}
}
創建一個按鈕代碼,
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(20, 20, 200, 44); // position in the cell and set the size of the button
[myButton setTitle:@"Login" forState:UIControlStateNormal];
// add targets and actions
[myButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
// add to a view
[cell.contentView addSubview:myButton];
你想索引2的按鈕權利? – iAmitWagh
嘿,超級棒!你在哪裏需要UIBUTTON? – Splendid