ho aggiunto il seguente codice alla mia appDelegate.miOS: come rilevare il movimento dell'oscillazione?
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (motion == UIEventSubtypeMotionShake)
{
// User was shaking the device. Post a notification named "shake".
[[NSNotificationCenter defaultCenter] postNotificationName:@"shake" object:self];
}
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
}
- (void)shakeSuccess
{
// do something...
}
e poi ho aggiunto:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
// INIT THE BACKGROUND PATH STRING
[self refreshFields];
[self.window addSubview:navController.view];
[self.window makeKeyAndVisible];
***[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shakeSuccess) name:@"shake" object:nil];***
return YES;
}
Quando inizio il mio app sul mio iPhone, il metodo denominato "shakeSuccess" non chiama . Cosa devo fare per implementare questa funzione nella mia app? qualche idea?
Fantastico! Funziona alla grande! Grazie mille. – Samblg
Lol e lui non l'ha mai fatto. –
"Il resto" è il punto. – Itachi