![](/img/trans.png)
[英]How do I trigger a segue to show a specific view, when not in a UIViewController?
[英]When do I init the segue controller UIViewController:prepareForSegue:?
那里有很多代碼,而且真的很多種。 有時segue控制器是:init'd,有時它是按原樣使用的。 顯然,在我:init之前將其設置為對象,但是在某些情況下,控制器無法按預期工作。 似乎在prepareForSegue上沒有任何文檔可以解決此問題。
另外,我可能還會補充說,有些開發人員甚至使用第三個選項,只是重新定義了他們呈現的內容。
我想念什么?
適用於iPad的示例UIImagePickerController 需要 :init(沒有照片加載到選擇器中),在iPhone上可以按預期工作。
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// This line is required for iPad functionality.
// UIImagePickerController *segueController = [((UIImagePickerController*)(segue.destinationViewController)) init];
// This line is all that is required on iPhone/iPod
UIImagePickerController *segueController = (UIImagePickerController*)segue.destinationViewController;
segueController.delegate = self;
segueController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
}
另一個SO Post: iOS7故事板圖像選擇器不起作用:(
編輯
似乎UIImagePickerController:initWithCoder可能有問題,但我不知道如何驗證。
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
UIImagePickerController *destinationController = (UIImagePickerController*)segue.destinationViewController;
destinationController.delegate = self;
destinationController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
}
您不需要[ alloc] init]
UIViewController
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.