【发布时间】:2015-01-17 19:16:13
【问题描述】:
我正在寻找一种将 Facebook 个人资料图片集成到我的 Titanium 应用程序中的方法。我在谷歌上搜索,然后我试过这个:
var imageAvatar = Ti.UI.createImageView({
image: "http://graph.facebook.com/"+FacebookUID+"/picture",
left:10, top:5,
width:50, height:50
});
但这不起作用,它不会显示人员 UID 的个人资料图片。
谁能帮帮我?非常感谢!
编辑 #1:我也尝试过使用 HTML,效果很好!而且 UID 不是空的,所以这不是问题。
编辑#2(更多代码):
var tableData = [];
for(var i=1; i < json.length; i++) {
alert(i+' - GAME #'+json[i].GameId);
var row = Ti.UI.createTableViewRow({
className:'forumEvent', // used to improve table performance
rowIndex:i, // custom property, useful for determining the row during events
height:110
});
var imageAvatar = Ti.UI.createImageView({
image: "http://graph.facebook.com/"+Ti.App.fb.uid+"/picture",
left:10, top:5,
width:50, height:50
});
row.add(imageAvatar);
var labelUserName = Ti.UI.createLabel({
color:'#576996',
font:{fontFamily:'Arial', fontSize:defaultFontSize+6, fontWeight:'bold'},
text:'Fred Smith ' + i,
left:70, top: 6,
width:200, height: 30
});
row.add(labelUserName);
var labelDetails = Ti.UI.createLabel({
color:'#222',
font:{fontFamily:'Impact', fontSize:defaultFontSize+2, fontWeight:'normal'},
text:'Replied to post with id 1234.',
left:70, top:44,
width:360
});
row.add(labelDetails);
tableData.push(row);
}
Ti.App.multi_tableView.data = tableData;
//另一个文件
Ti.App.multi_tableView = Ti.UI.createTableView({
top: 60,
bottom: 80
});
【问题讨论】:
-
你能再显示一些代码吗?如果我尝试您的基本示例,它会起作用。
-
我添加了更多代码 =)
-
谢谢,你能给 imageView 一个背景颜色,这样你就可以确定它是可见的吗?
-
完成 ;) 我只能看到背景颜色。我还尝试了另一个图像 url,首先使用 manuell 集成的 facebook uid,但它不起作用,然后我尝试了一个简单的图像 url,效果很好。也许你需要知道这个“for”动作是在一个json请求中
-
所以你尝试了一个已知的 id 硬编码,如下所示:graph.facebook.com/100005647326891/picture 这不起作用,但托管在其他地方的另一个图像可以吗?当您在 for 循环/ajax 请求之外将 Facebook 图像直接添加到您的应用程序时,它是否有效?
标签: javascript facebook facebook-graph-api titanium appcelerator