Microsoft Windows Phone 8.1 support ends (13 Jul 2017)

Microsoft has ended support for Windows Phone 8.1

Questions about iOS development and PDF

remove annotation from another view

More
9 years 5 months ago #11323 by Shades
Hello,

I would like to remove annotation from another view.When I use the NSNotificationCenter,the annotation is not removed.This how it should work:

1- I have a pdf where I draw an annotation
2- I submit the annotation and I navigate to the second view
3- I have a button in the second which remove the annotation without having to go to pdf.

Can you help me please ?
More
9 years 5 months ago #11327 by emanuele
Hi,

you can delete an annotation from another view with notification following these steps:
- Create a method that delete an annotation:
Code:
- (void)deleteAnnot:(NSNotification *)notification { PDFAnnot *annot = (PDFAnnot *)notification.object; [annot removeFromPage]; [m_view vRenderSync:m_annot_pos.pageno]; //or the specific page [self refresh]; }
- Create an observer for example in PDFView class that calls deleteAnnot method:
Code:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deleteAnnot:) name:@"delete-annot" object:nil];
- Post the notification from a different view (for example you can call pushViewController to show the view):
Code:
[[NSNotificationCenter defaultCenter] postNotificationName:@"delete-annot" object:_annot];

Pay attention to keep the annotation instance (annot) also in the second view and send it as notification param.
In this case is assumed that the pdf is opened.
Time to create page: 0.391 seconds
Powered by Kunena Forum