如果屏幕上显示的视图控制器是“PrimaryViewController”,我正在尝试显示警报我不确定如何获取视图控制器的名称,然后将其转换为 NSString ...任何帮助将不胜感激! !!
//get name of current view controller
UIViewController *currentVC = self.navigationController.visibleViewController;
if ([currentVC isEqualToString:@"PrimaryViewController"])
{
//display name of current view controller in alert
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Your current view controller:" message:currentVC delegate:nil
cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}