SDK 6.0을 기반으로하는 오래된 iOS 프로젝트를 유지 관리하고 있습니다.UIActionSheet를 대체하기 위해 UIAlertController를 사용하는 방법은 무엇입니까?
이 프로젝트에 대한 방법은 콤보 상자를 표시하는 데 사용됩니다
-(void) showComboBox:(UIView*)view:withOptions:(NSDictionary*)options
내 솔루션은 다음과 같이이다 :
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8) {
UIAlertController* alertController = [UIAlertController
alertControllerWithTitle:@"title"
message:@"message"
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* item = [UIAlertAction actionWithTitle:@"item"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
//do something here
//inform the selection to the WebView
...
[alertController dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[alertController dismissViewControllerAnimated:YES completion:nil];
}];
[alertController addAction:item];
[alertController addAction:cancelAction];
//I am not sure whether it's the right way
if ([view.nextResponder isKindOfClass:UIViewController.class]) {
UIViewController* vc = (UIViewController*)view.nextResponder;
[vc presentViewController:alertController animated:YES completion:nil];
}
가 적절한 솔루션인가요? UIAlertController가있는 UIViewController에 추가해야하지만 만에 UIView의 포인터를 얻을 수 있습니다, 그래서 나는 내가 원하는 것을 얻을 view.nextResponder을 사용하지만, 그것은 좋은 것이있다 :
이
내가 주로 우려에 대해 무엇인가 방법?
약간의 차이점을 제외하면 거의 동일합니다. 대신 UIViewController의 포인터를 직접 가져올 수 없으므로 대신 UIView.nextResponder를 사용자에게 알리고 싶습니다. –
코드에서'view' 란 무엇입니까? View Controller의 하위보기입니까? – Kampai
실제로 WebView는 phonegap과 같은 콤보 상자를 팝업으로 사용합니다. –