gpt4 book ai didi

ios - 是否有跟踪前一个屏幕并使用它来更改另一个屏幕中的内容的操作?

转载 作者:行者123 更新时间:2023-11-28 19:09:49 26 4
gpt4 key购买 nike

有没有这样的 Action :

if (previous_view.title = @"newyork")
{
mapPin.pinColor = MKPinAnnotationColorGreen;
}

if (previous_view.title = @"washington")
{
mapPin.pinColor = MKPinAnnotationColorPurple;
}

我正在创建一个有 map 的应用程序,如果你点击一个图钉的注释,它会进入一个有按钮图的屏幕,如果我点击它,那么图钉需要变成不同的颜色,我想知道是否存在这样一个基于名称或先前 View (它的来源)的任何其他属性的操作。

这是我在按下注释后用于转到下一个屏幕的代码:

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
if ([view.annotation.title isEqual: @"New York"])
{
newyork *controller1 = [[[newyork alloc] initWithNibName:@"newyork" bundle:nil] autorelease];
controller1.delegate = self;
controller1.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:controller1 animated:YES completion:nil];
}
}

这是 newyork.m 文件中的代码,它是按下 map 按钮时发生的操作:

- (IBAction)mapPressed:(id)sender
{
map *controller1 = [[[map alloc] initWithNibName:@"map" bundle:nil] autorelease];
controller1.delegate = self;
controller1.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:controller1 animated:YES completion:nil];
}

我真的需要帮助!!感谢您的帮助。

最佳答案

我假设“ View ”是指“ View Controller ”。

在那个假设之后。是的,如果您使用 UINavigationController 并将 View Controller 推到该导航 Controller 上,则可以检查此项。为此:

UIViewController *previousController = [self.navigationController.viewControllers objectAtIndex:self.navigationController.viewControllers.count - 2];

if ([previousController.title isEqual:@"something"]) {
// Do Something
}

但这不是建议的方法。你不应该依赖你的导航 Controller 堆栈来对你的 View Controller 进行条件操作。您应该将此参数传递给您的 View Controller ,最好是在初始化时。喜欢:

[[SomeViewContoller alloc] initWithStateName:stateName];

关于ios - 是否有跟踪前一个屏幕并使用它来更改另一个屏幕中的内容的操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16718771/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com