我创建了一个包含20个单元格的tableview.
当我选择第一行时,它会在上面显示复选标记.

但是当我滚动tableview时,它不仅在tableview单元格上有一个复选标记.
它也显示在另一个细胞上.

这有什么问题?
self.dataAry = [NSArray arrayWithObjects:@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",@"19",nil];
marks = [NSMutableArray new];
for (int i = 0 ; i < [self.dataAry count]; i++) {
[marks addObject:@"NO"];
}
- (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.textLabel.text = [dataAry objectAtIndex:indexPath.row];
if ([[marks objectAtIndex:indexPath.row] isEqualToString:@"YES"]) {
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
}else {
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
// Configure the cell.
return cell;} …Run Code Online (Sandbox Code Playgroud) 您好
我知道ipad键盘不喜欢iphone可以设置"UIKeyboardTypeNumberPad"!!
但如果我想它只能输入并在文本字段显示数字0到9.
如何比较文本字段中的用户键是否为数字?
预先感谢.
微型
例如:
NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
[user setObject:textField1.text forKey:@"receive_text1"];
[user setObject:textField2.text forKey:@"receive_text2"];
[user synchronize];
Run Code Online (Sandbox Code Playgroud)
如果我离开这个应用程序,就像从背景到前景,或重新启动应用程序
NSUserDefaults中的对象是否仍然可以获取我之前设置的数据?