如何從Scroll子視圖中移除UITextField
的數組,最初在我調用API時我根據Count創建了一些數組值我已經在My View中創建了Dynamic UITextFiled
但我知道如何刪除子視圖如何從子視圖中刪除動態UITextField
這裏我的示例代碼:
// NSArray *strings;
// UIScrollView *scrollView;
// NSMutableArray *textFields;
self.textFields = [NSMutableArray array];
const CGFloat width = 320;
const CGFloat height = 31;
const CGFloat margin = 0;
CGFloat y = 0;
for(NSString *string in strings) {
UITextField *textField = [[UITextField alloc]
initWithFrame:CGRectMake(0, y, width, height)];
textField.delegate = self;
textField.text = string;
[scrollView addSubview:textField];
[textFields addObject:textField];
[textField release];
y += height + margin;
}
scrollView.contentSize = CGSizeMake(width, y - margin);
你想刪除所有的textFields? –
爲每個文本字段使用標籤(簡單地使用數組索引作爲標籤)。所以你可以刪除你需要刪除的任何文本字段。 – jegadeesh
你想只刪除那些使用這種方法添加的textField? –