新闻源未显示在 TableView Controller 中。与新闻源 View Controller 链接的BuyerSocialPage 具有 BuyerSocialPage.h 文件
@interface BuyerSocialPage : UIViewController <UITableViewDataSource,UITableViewDelegate>
@end
@implementation BuyerSocialPage
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.tableView.delegate=self;
UINib * firstNib = [UINib nibWithNibName:@"BSPFirstCell" bundle:nil];
[self.tableView registerNib:firstNib forCellReuseIdentifier:@"BSPFirstCell"];
UINib * secondNib = [UINib nibWithNibName:@"BSPSecondCell" bundle:nil];
[self.tableView registerNib:secondNib forCellReuseIdentifier:@"BSPSecondCell"];
UINib * thirdNib = [UINib nibWithNibName:@"BSPThirdCell" bundle:nil];
[self.tableView registerNib:thirdNib forCellReuseIdentifier:@"BSPThirdCell"];
UINib * fourthNib = [UINib nibWithNibName:@"BSPFourthCell" bundle:nil];
[self.tableView registerNib:fourthNib forCellReuseIdentifier:@"BSPFourthCell"];
self.view.backgroundColor = [UIColor whiteColor];
[self getBuyerSocialPage];
if (self.revealViewController) {
[_sidebarButton addTarget:self.revealViewController action:@selector(revealToggle:) forControlEvents:UIControlEventTouchUpInside];
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
}
}
-(void)getBuyerSocialPage {
}
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
int row = (int)indexPath.row;
if (row == 0) {
return 324;
}
else if (row == 1)
{
return 152;
}
else if (row == 2)
{
return 152;
}
else
{
return 152;
}
}
@end
登录后您将看到主屏幕。从顶部的侧面菜单栏中选择“新闻源”,它应该显示新闻源。但它没有显示新闻源。Api 在 postman 上正确运行
如何在表格 View 中获取新闻源?
最佳答案
您的网址&pageno=1
中缺少页码。
您的网址如下所示: http://api.shoclef.com/api/NewsFeed?user_id=1164
应该是这样的: http://api.shoclef.com/api/NewsFeed?user_id=1164&pageno=1
在 API Manager 类中尝试此操作。对我来说工作得很好。
NSString * url = [NSString stringWithFormat:@"%@NewsFeed?user_id=%I&pageno=1",API_BASE_URL,userID];
图像更新
在 NewsFeedNew 类
的 cellForRowAtIndexPath
函数中更新此代码
NSString *strUrl = [self.images objectAtIndex:indexPath.row].image;
strUrl = [strUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
[cell.image sd_setImageWithURL:[NSURL URLWithString:strUrl]];
关于ios - Tableview 不使用 Objective-c 显示 NewsFeed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48820641/