【发布时间】:2015-07-15 05:17:47
【问题描述】:
我有一个标题 UIView,我正在尝试将 JSON 数据加载到其中,但是根本没有显示任何信息,如图所示:
这是我加载标题视图的方法:
- (ForeignInstagramViewHeader *)header {
if (!_header) {
_header = [[ForeignInstagramViewHeader alloc] initWithFrame:CGRectMake(0, 0, 320, 150) withUserData:self.instaUser];
NSString *userID = self.instagramData[@"user"][@"id"];
[self getInstaDataWithUserID:userID];
_header.instaUser = self.instaUser;
}
return _header;
}
这是我获取 Instagram 数据的方法:
- (void)getInstaDataWithUserID:(NSString *)user {
NSString *path = [NSString stringWithFormat:@"users/%@", user];
[[InstagramClient sharedClient] getPath:path parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"%@",responseObject);
self.instaUser = [[InstagramUser alloc] init];
[self.instaUser setBio:responseObject[@"data"][@"bio"]];
self.instaUser.followed_by = responseObject[@"data"][@"counts"][@"followed_by"];
self.instaUser.follows = responseObject[@"data"][@"counts"][@"follows"];
self.instaUser.media = responseObject[@"data"][@"counts"][@"media"];
self.instaUser.full_name = responseObject[@"data"][@"full_name"];
self.instaUser.idvalue = responseObject[@"data"][@"id"];
self.instaUser.profile_picture = responseObject[@"data"][@"profile_picture"];
self.instaUser.username = responseObject[@"data"][@"username"];
self.instaUser.website = responseObject[@"data"][@"website"];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
这是我的标题 View Class.h :
@interface ForeignInstagramViewHeader : UIView
@property (nonatomic, strong) UIImageView *profilePic;
@property (nonatomic, strong) UILabel * nameString;
@property (nonatomic, strong) UILabel * postCount;
@property (nonatomic, strong) UILabel * postString;
@property (nonatomic, strong) UILabel * followerCount;
@property (nonatomic, strong) UILabel * followerString;
@property (nonatomic, strong) UILabel * followingCount;
@property (nonatomic, strong) UILabel * followingString;
@property (nonatomic, strong) UILabel * bioString;
@property (nonatomic, strong) UILabel * websiteString;
@property InstagramUser *instaUser;
- (id)initWithFrame:(CGRect)frame withUserData:(InstagramUser *)instagram;
@end
【问题讨论】:
-
用户数据
getPath:完成后需要更新数据到header view。 -
@Akhilrajtr 我该怎么做??
标签: ios objective-c json uiview uiviewcontroller