在此輸入代碼我在提示提醒時無法返回到先前的視圖控制器。在提醒後打開新的視圖控制器
我想要做的是讓用戶輸入數據,然後出現一條警告,說它已成功,然後返回到前一個視圖控制器。
我目前還沒有代碼這樣做,並正在尋求與我應該把什麼幫助。你的UIAlertView中UIAlertviewController的
UIAlertView *enterAlert = [[UIAlertView alloc]initWithTitle:nil message:@"Entry was recorded" delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];
[enterAlert show];
使用委託方法
- (IBAction)saveLabel:(id)sender
{
NSArray *data = [[NSUserDefaults standardUserDefaults] objectForKey:@"DATA"];
NSMutableArray *currentDataArray;
if (data == nil)
{
currentDataArray = [[NSMutableArray alloc]init];
}
else
{
currentDataArray = [[NSMutableArray alloc]initWithArray:data];
}
[currentDataArray addObject:self.textField.text];
[[NSUserDefaults standardUserDefaults] setObject:currentDataArray forKey:@"DATA"];
}
- (IBAction)enterButtonPressed:(id)sender
{
NSLog(@"enterButtonPressed");
UIAlertView *enterAlert = [[UIAlertView alloc]initWithTitle:nil message:@"Entry was recorded" delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil];
[enterAlert show];
}
這很有用,謝謝! 你能告訴我CATransaction做了什麼嗎? –
https://developer.apple.com/library/prerelease/ios/documentation/GraphicsImaging/Reference/CATransaction_class/index.html – Mukesh