The following is my stuff….
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([object isKindOfClass:[UIAccelerometer class]]) {
NSNumber *interfaceValue = [change objectForKey:NSKeyValueChangeNewKey];
UIInterfaceOrientation toInterfaceOrientation = [interfaceValueintValue];
//here is my code....
}
If I understand you correctly, you would like to execute certain code when a keyValue changes – and you would also like to execute this code in viewWillAppear. Rather than trying to programmatically trigger the KVO method, simply create a separate function that you can call from both locations:
If I am completely missing the mark, then please edit your question and add more detail to your explanation of your problem.