Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在UIAlertView中放置UIWebView?_Iphone_Objective C - Fatal编程技术网

Iphone 如何在UIAlertView中放置UIWebView?

Iphone 如何在UIAlertView中放置UIWebView?,iphone,objective-c,Iphone,Objective C,我已尝试使用以下代码将WebView添加到AlertView: - (void)viewDidLoad { search = [[UIAlertView alloc] initWithTitle:@"title" message:@"iGoogle" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Search", nil]; [search addSubview:googleView]; googleView = [[U

我已尝试使用以下代码将
WebView
添加到
AlertView

- (void)viewDidLoad {
search = [[UIAlertView alloc] initWithTitle:@"title" message:@"iGoogle" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Search", nil];
[search addSubview:googleView];
googleView = [[UIWebView alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[search show];

[search release];

[super viewDidLoad]; }

但是,只有AlertView显示,没有WebView。另外,我在哪里可以获得更多关于添加CGRectMakes之类的东西的详细信息?

您是否尝试将
addSubview:googleView
调用字符串与
googleView=
string进行交换?

这里有一个链接,指向我不久前用于将子视图添加到UIAlertView的内容。“诀窍”是添加一个消息参数,使警报视图的高度增加,然后在其上放置一个子视图。我从未尝试过使用web视图


还可以使用url初始化webview,并根据需要实现委派。

尝试添加
[search addSubview:googleView]分配googlview后…

尝试此操作

- (void)viewDidLoad { googleView = [[UIWebView alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)]; search = [[UIAlertView alloc] initWithTitle:@"title" message:@"iGoogle" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Search", nil]; [search addSubview:googleView]; [search show]; [search release]; [super viewDidLoad]; } -(无效)viewDidLoad { googleView=[[UIWebView alloc]initWithFrame:CGRectMake(12.0,45.0,260.0,25.0)]; 搜索=[[UIAlertView alloc]initWithTitle:@“标题”消息:@“iGoogle”委托:无取消按钮:@“取消”其他按钮:@“搜索”,无]; [搜索添加子视图:谷歌视图]; [搜寻节目];; [搜索发布]; [超级视图下载]; }
首先初始化webview的内存,然后将其添加到警报视图中。

UIAlertView
在iOS 8中不推荐使用

要实现相同的功能,请使用
UIAlertController

NSURL *url = [[NSBundle mainBundle] URLForResource:@"page" withExtension:@"html"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];  
[webView loadRequest:request];

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"HTML" message:nil preferredStyle:UIAlertControllerStyleAlert];
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 60, 60)];
webView.backgroundColor = [UIColor clearColor];
[alert.view addSubview:webView];

[self presentViewController:alert animated:YES completion:nil];

你能在这里查看这篇文章吗?如果成功了,那就试着接受答案哈哈,很好的通知。。我们都忽略了这一点:)@richard:SO没有任何东西可以发送个人信息:(当我尝试此功能时,我的网络视图位于警报顶部,而不是警报的一部分。