1

我在 UIVIewController 中有一个 UIButton,当我按下按钮时我需要将它推送到 UIVIew。但这给了我警告incompatible pointer type sending

如何做到这一点我在做什么:

-(void)press{
    displayView *disp=[[displayView alloc]init];
    [self presentModalViewController:disp animated:No];
}

这给了我警告并使我的应用程序崩溃。

4

1 回答 1

4

presentModalViewController accepts a UIViewController instance (not UIView). If you want to display a particular view, place it within a view controller first.

UIViewController *viewController = [[UIViewController alloc] init];
DisplayView *displayView = [[DisplayView alloc] init];
[viewController.view addSubview: displayView];
[self presentModalViewController:viewController animated:NO];
于 2012-12-27T19:48:15.323 回答