6

我正在研究一個在detailViewController中提供一些數據的應用程序。我在導航欄中有一個rightBarButton,它提供了一個UIActivityViewController,它充滿了我自己的UIActivity sublclassed項目。他們大多數工作正常,因爲他們只是從細節視圖改變一個小方面的數據,但我需要其中之一打開一個modalViewController時選擇。我一直從控制檯收到以下警告.....如何從UIActivity View Controller中取出的UIActivity項目中顯示ModalViewController?

Warning: Attempt to present <UINavigationController: 0x1fd00590> 
on <UITabBarController: 0x1fde1070> which is already presenting <MPActivityViewController: 0x1fd2f970> 

我想這是值得注意的是,應用程序不會崩潰,但模態視圖不出現任何。我假設UIActivityViewController本身就是一個模態視圖,你只能一次顯示其中的一個,因此任務就是在ActivityView消失後找出如何執行我的segue,但那是我難以理解的地方。我歡迎任何幫助,想法或反饋。我試過谷歌,但沒有太多的運氣,我假設,因爲UIActivityViewController是如此新。

這是我設置到目前爲止, 我的UIActivity對象有一個委託設置爲detailViewController的自定義協議,讓detailViewController執行數據更改,然後更新其視圖。

爲應該提出的模態視圖控制器的問題的活動我已經嘗試了幾種方法,都獲得相同的警告。


這些都不行!


1)簡單地試圖執行賽格瑞從我的委託方法

- (void) activityDidRequestTransactionEdit 
{ 
    NSLog(@"activityDidRequestTransactionEdit"); 
    [self performSegueWithIdentifier:@"editTransaction" sender:self]; 
} 

2)試圖在UIActivityViewController設置完成塊和具有我的委託方法設置該模態的視圖應該是一個布爾標記示出(self.editor)

[activityViewController setCompletionHandler:^(NSString *activityType, BOOL completed) { 
    NSLog(@"completed dialog - activity: %@ - finished flag: %d", activityType, completed); 
    if (completed && self.editor) { 
     [self performSegueWithIdentifier:@"editTransaction" sender:self]; 
    } 
}]; 

3)子類UIActivityViewController本身,給它的DetailView作爲代表,和覆蓋它的dismissViewControllerAnimated:方法與我自己完成的塊

- (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion 
{ 
    [super dismissViewControllerAnimated:flag completion:^{ 
     [self.MPActivityDelegate activityDidRequestTransactionEdit]; 

    }]; 
} 

工作方案


在UIActivity子類,你需要重寫此方法,像這樣

- (UIViewController *) activityViewController { 
    MPEditMyDataViewController *controller = [[MPEditMyDataViewController alloc] init]; 
    controller.activity = self; // more on this property below 
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller]; 
    return navController; 
} 

在您的MPEditMyDataViewController.h(t 你需要的屬性回活動子類,像這樣

@property (strong, nonatomic) MPEditMyDataActivity *activity; 
在MPEditMyDataViewController

他視圖控制器所選擇的動作應該產生)。米

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] 
            initWithBarButtonSystemItem:UIBarButtonSystemItemCancel 
            target:self 
            action:@selector(cancel)]; 

    self.navigationItem.leftBarButtonItem = cancelButton; 
} 
// here's how you dismiss the view controller when you are done with it 
// after saving the changes to your data or whatever the view controller is supposed to do. 
-(void) cancel 
{ 
    NSLog(@"Cancel Button Pushed"); 
    [self.activity activityDidFinish:YES]; 
} 
@end 

回答

3

做了一些更多的文檔挖掘並從這裏返回它,而不是試圖從Segue公司就發現了UIActivity子類

- (UIViewController *) activityViewController 

它得到我的視圖控制器彈出像我想這個方法我的detailViewController。現在想辦法解決這個問題怎麼解決它!

+0

只是爲了防止其他人遇到問題,請在上面的修改中查看解決方案示例。 – vichudson1 2013-03-12 21:44:12

相關問題