我正在研究iphone的圣经阅读器应用程序。当我们点击圣经的任何一节时,它会弹出一个菜单,其中包含一些控制器,如书签,备注视图等。音符视图有一个隐藏的刻度标记。我的要求如下:
我的代码是
-(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];
}
使用上面的代码我保存了笔记。它显示在tableviewcontroller中,用户可以根据需要查看。
更新:
-(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];
}
然后在我的弹出窗口中显示是mainpopup,它是在我点击单元格代码时出现的
- (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];
}
}
答案 0 :(得分:1)
你试过这个:
[yourBtnOrImage setHidden:YES];
或
[yourBtnOrImage setEnabled:YES];
如果是,请使用上面的代码检查一节经文是否已经有说明,否则请使用以下代码:
[yourBtnOrImage setHidden:NO];
或
[yourBtnOrImage setEnabled:NO];
我希望你能找到它。
更新:
NSMutableDictionary *notes = [[NSMutableDictionary alloc] init]; //Initialize like that for you
//Add a note :
[notes setValue:textView.text forKey:[NSString stringWithFormat:@"%@ %@:%@",delegate.selectedBook,delegate.selectedChapter,delegate.selectedIndex]];
检查是否存在备注的代码:
if ([notes objectForKey:[NSString stringWithFormat:@"%@ %@:%@",delegate.selectedBook,delegate.selectedChapter,delegate.selectedIndex]] == nil) {
[yourBtnOrImage setHidden:YES];
}
答案 1 :(得分:0)
有几种方法可以做到这一点,我能想到的是: 在delegate.notesArray中为经文编号添加一个字段。显示经文时,通过数组并检查特定的经文是否附有说明。 编辑: 哦,是的,就像A10说NSMutableDictionnary可能更容易证明