I am working on a bible reader application for iphone. When we click on any verse of the bible it pops up a menu which contains some controllers like bookmark, notes view etc. The note view has a hidden tick mark. My requirement is as follows :
- User should be able to select a verse, add a note to it and save it
- When the same verse is selected again, the tick mark should appear indicating that a note has already been added.
My code is
-(IBAction)_clickbtnNotesMain:(id)sender
{
[self.view addSubview:NoteView];
_lblnotegns.text = localStringValueverseno;//localStringValueverseno which holds the verse no: from the tableview,the verse and verse no: shown in tableview
//NoteView is the notepopup ie,write note in Noteview
}
-(IBAction)_clickbtnsaveNote:(id)sender
{
[delegate.indexArray addObject:[NSString stringWithFormat:@"%@ %@:%@",delegate.selectedBook,delegate.selectedChapter,delegate.selectedIndex]];
[delegate.notesArray addObject:textView.text];
NSString *DataPath = [Malayalam_BibleAppDelegate getPath];
[delegate.data writeToFile:DataPath atomically:YES];
proAlertView *alert = [[proAlertView alloc]initWithTitle:@"NOTES" message:@"Notes Saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert setBackgroundColor:[UIColor colorWithRed:0.255 green:0.218 blue:0.185 alpha:1.0] withStrokeColor:[UIColor colorWithHue:0.625 saturation:0.0 brightness:0.8 alpha:0.8]];
[alert show];
[alert release];
}
With the above code I save the note. It is displayed in a tableviewcontroller which the user can see if he wants.
UPDATE:
-(IBAction)_clickbtnsaveNote:(id)sender
{
[delegate.indexArray addObject:[NSString stringWithFormat:@"%@ %@:%@",delegate.selectedBook,delegate.selectedChapter,delegate.selectedIndex]];
[delegate.notesArray addObject:textView.text];
[notes setValue:textView.text forKey:[NSString stringWithFormat:@"%@ %@:%@",delegate.selectedBook,delegate.selectedChapter,delegate.selectedIndex]];
NSString *DataPath = [Malayalam_BibleAppDelegate getPath];
[delegate.data writeToFile:DataPath atomically:YES];
proAlertView *alert = [[proAlertView alloc]initWithTitle:@"NOTES" message:@"Notes Saved" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert setBackgroundColor:[UIColor colorWithRed:0.255 green:0.218 blue:0.185 alpha:1.0] withStrokeColor:[UIColor colorWithHue:0.625 saturation:0.0 brightness:0.8 alpha:0.8]];
[alert show];
[alert release];
}
then in my popup comes view that is mainpopup,it comes when i tap the cell codeis
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([notes objectForKey:[NSString stringWithFormat:@"%@ %@:%@",delegate.selectedBook,delegate.selectedChapter,delegate.selectedIndex]] == nil) {
[notetickimage setHidden:YES];
[self.view addSubview:MainPopupView];
}
}
Have you tried this :
or
You just have to check if there is already a note on a verse if yes use the code above, otherwise use the code below :
or
I hope its what you are looking for.
UPDATE :
Code to check if a note exist :