我在Swift中看到了這個問題的解決方案。誰能幫我嗎?從TableViewCell中顯示AlertController,Objective-C
我在TableViewController類此方法:
- (void)presentAlert {
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:@"Flag Content"
message:@"Are you sure you want to report this post?"
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"OK", @"OK action")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
NSLog(@"OK action");
[cell.feedItem incrementKey:@"flagTotal"];
[cell.feedItem saveInBackground];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:cell.flagButton cache:YES];
[UIView commitAnimations];
// Set flagButton image to checked image
[cell.flagButton setImage:[UIImage imageNamed:@"filledFlagButtonIcon"] forState:UIControlStateNormal];
[self dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:okAction];
[self presentViewController:alert animated:YES completion:nil];
preferredStyle:UIAlertControllerStyleAlert];
我希望簡單地調用從IBAction爲這種方法在像格:
- (IBAction)flagTapped:(id)sender {
_tableView = [[FeedTableViewController alloc] init];
[_tableView presentAlert];
}
你要調用一個alertview時選擇特定的一行在表視圖? – UlyssesR