Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.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
如何在基于UIView的iphone应用程序中添加类似facebook的按钮?_Iphone_Objective C - Fatal编程技术网

如何在基于UIView的iphone应用程序中添加类似facebook的按钮?

如何在基于UIView的iphone应用程序中添加类似facebook的按钮?,iphone,objective-c,Iphone,Objective C,我是c目标的新手。我需要在基于UIView的应用程序中添加类似facebook的按钮。对于这种情况,我创建了一个操作按钮,并编写了以下代码: UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 460.0)]; NSString *path = [[NSBundle mainBundle] bundlePath]; NSURL *baseURL = [NSURL fileURLWit

我是c目标的新手。我需要在基于UIView的应用程序中添加类似facebook的按钮。对于这种情况,我创建了一个操作按钮,并编写了以下代码:

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0,  0.0, 320.0, 460.0)];
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];

NSString *htmlString = [NSString stringWithFormat:@"<html>\
<body style=\"color: #000000; font-family: Helvetica; font-size: 10pt;\">\
<tr>\
<td colspan=2>\
<a style=\"color: #000000; font-family: Helvetica; font-size: 10pt; width:50px; height:20px;\" href=https://www.facebook.com/abc..><img src=\"facebook_like.png\" width=50 height=50 style=\"float:left; \" /></a><br>\
    </td>\
</tr>\
</body>\
</html>"];
[webView loadHTMLString:htmlString baseURL:baseURL];
UIWebView*webView=[[UIWebView alloc]initWithFrame:CGRectMake(0.0,0.0320.0460.0)];
NSString*path=[[NSBundle mainBundle]bundlePath];
NSURL*baseURL=[NSURL fileURLWithPath:path];
NSString*htmlString=[NSString stringWithFormat:@]\
\
\
\

\ \ \ \ "]; [webView loadHTMLString:htmlString baseURL:baseURL];

但是当我点击action按钮时,它就不起作用了。

Facebook在其SDK中没有提供此功能,但有一个开源的Github项目,您可以使用或查看他们是如何做到的。

您可以使用UIButton。不过,我不太清楚你想要实现什么

UIButton *btn = [UIButton buttonWithType: UIButtonTypeCustom];
btn.frame = CGRectMake(0.0,  0.0, 320.0, 460.0);
[btn setImage:[UIImage imageNamed:@"facebook_like.png"] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(buttonPushed:) forControlEvents:UIControlEventTouchUpInside];

希望这能有所帮助。别忘了将-buttonPushed:(id)sender添加到该类中。因此,请将其添加到您的视图中。

我现在明白了。Facebook的“喜欢”按钮。不是像Facebook那样的按钮。哇!愚蠢的时刻。谢谢,这是脸谱“喜欢”按钮。实际上,我使用了一个类似于-(iAction)facebookBtn:(id)sender{/----这里我使用了上面的代码,我已经发布了}。但它将进入页面,但我没有得到任何返回按钮,我无法解决这个问题。我建议使用@coneybeare发布的内容。这看起来正是你想要的。你能给我提供链接吗?