{
Flows = (
flow456
);
flow456 = (
format789,
format123
);
format123 = {
row1 = {
label = Price;
textbox = {
height = 111;
width = 333;
};
};
row2 = {
button = yes;
};
};
format123Rows = (
row1,
row2
);
format789 = {
row1 = {
label = Price;
textbox = {
height = 111;
width = 333;
};
};
row2 = {
button = yes;
};
};
format789Rows = (
row1,
row2
);
}
上面是我要在iphone屏幕上显示的json对象。哪个是在屏幕上显示数据的最佳布局?我试过UIView,UIStackView但是无法做到。如何以行方式显示它? 如图像Click here to see image
所示答案 0 :(得分:0)
您需要将json对象转换为String并在UITextview上显示。如果您正在从bundle中读取JSON对象,则可以在下面使用。
**NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"JSON"];
//création d'un string avec le contenu du JSON
NSString *myJSON = [[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL];
self.textview.text = myJSON;**
如果您从webservice获取JSON对象,可以尝试以下方法。
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:JSONDic
options:NSJSONWritingPrettyPrinted
error:&error];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];