哈,我正在做一个应用程序,它有一个共享笔记选项到印象笔记我成功地完成了它,我有一个包含文本的表格视图和一个用于将这些文本上传到印象笔记的按钮,如果用户单击单元格,则附加复选标记来了,他可以通过使用对uploade的复选标记来选择经文。但我的问题是当用户单击一个单元格并点击上传按钮时,它将上传行中的所有值,不仅是选定的行,而且是整行。我的代码是Buttonclick:
-(IBAction)sendNoteEvernote:(id)sender{
NSMutableString *str = [[NSMutableString alloc] initWithString:@"NOTES:"];
for (int i = 0; i<[appDelegate.notesArray count]; i++) {
// UPLOAD STRINGS HERE
if (selected[i])
[str appendFormat:@"%@ ,",[appDelegate.notesArray objectAtIndex:i]];
NSString * ENML= [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">\n<en-note>%@",str];
}
str 是在 selectrowatindexpath 中上传代码的值:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSUInteger row = [indexPath row];
selected[row] = !selected[row];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = selected[row] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
in.hiBOOLEAN selected;
在viewdidload 中声明
for ( int i=0; i<[appDelegate.notesArray count]; i++) {
selected[i] = YES;
}