【发布时间】:2016-05-06 11:00:55
【问题描述】:
每当我尝试从单元格中获取数据时,它都会返回空值,但是我发现我无法从 TableView 向上/向下滚动的单元格中读取数据
这是我用来保存数据的代码:
NSMutableArray *arrTmp = [[NSMutableArray alloc] init];
for(int i = 0; i<[tblView numberOfRowsInSection:0]; i++){
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:i inSection:0];
FUCellView *cell = [tblView cellForRowAtIndexPath:indexPath];
UITextField *tfNo = (UITextField *)[cell viewWithTag:i + 100];
UIButton *btnTime = (UIButton *)[cell viewWithTag:i + 200];
UITextField *tfVisit = (UITextField *)[cell viewWithTag:i + 300];
UIButton *btnProvider = (UIButton *)[cell viewWithTag:i + 400];
NSMutableDictionary *theDictionary = [[NSMutableDictionary alloc] init];
if([tfNo.text length] > 0 && tfNo.text != nil){
NSString* str = [tfNo.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
[theDictionary setObject:str forKey:@"number"];
}
else{
[theDictionary setObject:@"" forKey:@"number"];
}
if([btnTime.titleLabel.text length] > 0 && btnTime.titleLabel.text != nil){
NSString* str = [btnTime.titleLabel.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
[theDictionary setObject:str forKey:@"time"];
}
else{
[theDictionary setObject:@"" forKey:@"time"];
}
if([tfVisit.text length] > 0 && tfVisit.text != nil){
NSString* str = [tfVisit.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
[theDictionary setObject:str forKey:@"visit_type"];
}
else{
[theDictionary setObject:@"" forKey:@"visit_type"];
}
if([btnProvider.titleLabel.text length] > 0 && btnProvider.titleLabel.text != nil){
NSString* str = [btnProvider.titleLabel.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
[theDictionary setObject:str forKey:@"provider"];
}
else{
[theDictionary setObject:@"" forKey:@"provider"];
NSLog(@"ProviderELse");
}
[arrTmp addObject:theDictionary];
【问题讨论】:
标签: objective-c uitableview xcode7