嗨我是非常新的ios和我的应用程序我在UIView xib文件上以编程方式加载UITableView但是使用我的下面的代码UItableList没有添加我的UIView xib文件我在这里做了什么错误请帮助我一些
#import "FaqQuestionsClass.h"
@implementation FaqQuestionsClass
{
BackGroundClass * Bg;
UITableView * tableList;
}
@synthesize mainView;
-(instancetype)initWithFrame:(CGRect)frame{
if (self = [super initWithFrame:frame]) {
[self loadingView];
}
return self;
}
- (void)awakeFromNib{
[super awakeFromNib];
[self loadingView];
}
-(void)loadingView{
Bg = [[BackGroundClass alloc]init];
tableList = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
tableList.translatesAutoresizingMaskIntoConstraints = NO;
tableList.dataSource=self;
tableList.delegate=self;
tableList.backgroundColor = [UIColor orangeColor];
tableList.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
tableList.separatorStyle = UITableViewCellSeparatorStyleNone;
tableList.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
[tableList registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
[mainView addSubview:tableList];
}
//UITableView Delegate Methods:-
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 10;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath] ;
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = @"hello";
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 50;
}
@end
答案 0 :(得分:0)
您正在为tableview设置错误的框架。 var app = angular.module('app',[]);
app.controller('EventController',function EventController($scope) {
$scope.count = 0;
var arr = [], subArr = [], currentIndex;
for(var i = 0; i < 7; i++) {
arr.push(i)
}
$scope.next = function() {
currentIndex = $scope.count;
subArr = [];
$scope.count++;
subArr.push(currentIndex);
subArr.push(currentIndex+1);
subArr.push(currentIndex+2);
if(arr.indexOf(currentIndex+1) == -1) {
console.log(currentIndex+1,'Element not available');
$scope.count = 0;
currentIndex = $scope.count
}
console.log(subArr);
}
});
表示表格视图在CGRectZero
上不可见。更新以下行
mainView
使用: -
tableList = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];