Objective c 如何获取用户';当选择过于复杂而无法使用UIAlertView时,请正确选择

Objective c 如何获取用户';当选择过于复杂而无法使用UIAlertView时,请正确选择,objective-c,ios,uiviewcontroller,delegates,nsobject,Objective C,Ios,Uiviewcontroller,Delegates,Nsobject,我已经为这个问题挣扎了一段时间,所以任何帮助都将不胜感激 情况如下:我的应用程序有一个名为InitialViewController的UIViewController子类。此视图控制器有一个UIButton,当按下该按钮时,它会创建一个名为MyEngine的NSObject子类。大概是这样的: @interface InitialViewController : UIViewController <MyEngineDelegate> ... @end @implementation

我已经为这个问题挣扎了一段时间,所以任何帮助都将不胜感激

情况如下:我的应用程序有一个名为
InitialViewController
UIViewController子类。此视图控制器有一个UIButton,当按下该按钮时,它会创建一个名为
MyEngine
NSObject
子类。大概是这样的:

@interface InitialViewController : UIViewController <MyEngineDelegate>
...
@end

@implementation InitialViewController
...
-(IBAction)pressedButton:(id)sender {
    MyEngine *engine = [[MyEngine alloc] init];
    [engine start];
}
ConflictViewController
非常简单。它只是等待用户做出决定,当用户按下按钮时,它会将消息发送给
代表
,并自行退出

-(IBAction)didSelectConflict:(id)sender {
    UISegmentedControl *seg = (UISegmentedControl*) sender;
    [self.delegate didResolveConflictChoice:seg.selectedSegmentIndex];
    [self dismissModalViewControllerAnimated:YES];
}
我检查了所有连接,所有学员都正常工作。 问题在于: 当MyEngine在它的
didSelectConflict:
实现中收到用户的选择时,它无法正常继续,因为它的所有属性都已变为
null

MyEngine
显示
ConflictViewController
时,程序继续执行,当
start
完成时,返回到
pressed按钮:
,当此方法关闭时,
MyEngine
对象被释放

我想知道的是是否有办法解决这个问题?有人用另一种方式做过类似的事情吗? 这里的问题是:当选择太复杂而无法使用
UIAlertView
时,如何正确地获得用户的选择


对不起,问题太长了,我尽量简化了。感谢您的时间,非常感谢您提供的任何链接、评论或任何形式的帮助

-(void) startWithDelegate:(id)del {
        ConflictViewcontroller *cvc = [[ConflictViewController alloc] initWithNibName:@"ConflictViewController" bundle:nil];
        cvc.modalPresentationStyle = UIModalPresentationFormSheet;
        cvc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        cvc.delegate = del;
        UIWindow *window = [(MyAppDelegate *) [[UIApplication sharedApplication] delegate] window];
        [[window rootViewController] presentModalViewController:cvc animated:YES];
}

InitialViewController
中实现
didResolveConflictChoice:
,并在那里获取代理调用。


如果合适,可以使用。

为什么要在iAction中初始化
MyEngine*引擎
,如果要使用MyEngine对象,为什么不在
InitialViewController
中进行全局声明,然后在iAction中调用
[engine start]
。然后,当委托方法返回所选索引时,您可以将其应用于初始视图控制器中的全局int,然后继续前进。希望这是有意义的

此解决方案的问题是我需要
MyEngine
的属性来处理
didResolveConflictChoice:
。我将看一看UIActionSheet。感谢您的回答不幸的是,
UIActionSheet
只是一组按钮,与
UIAlertView
完全相同,请尝试上述方法。另一方面,您可以像本教程一样将表视图置于警报视图中。这是有道理的哈哈哈。不过,我希望我知道一个更好的方法来处理这种情况
-(void) startWithDelegate:(id)del {
        ConflictViewcontroller *cvc = [[ConflictViewController alloc] initWithNibName:@"ConflictViewController" bundle:nil];
        cvc.modalPresentationStyle = UIModalPresentationFormSheet;
        cvc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        cvc.delegate = del;
        UIWindow *window = [(MyAppDelegate *) [[UIApplication sharedApplication] delegate] window];
        [[window rootViewController] presentModalViewController:cvc animated:YES];
}
-(IBAction)pressedButton:(id)sender {
    MyEngine *engine = [[MyEngine alloc] init];
    [engine startWithDelegate:self];
}