Ios 未显示表视图数据
我做了一个视图控制器,上面有两个视图。在俯视图中,我插入了一个表视图,其中包含静态单元格和基本单元格。当我运行程序时,我在tableview中手动输入的数据不会显示 我的代码: ViewController.hIos 未显示表视图数据,ios,uitableview,Ios,Uitableview,我做了一个视图控制器,上面有两个视图。在俯视图中,我插入了一个表视图,其中包含静态单元格和基本单元格。当我运行程序时,我在tableview中手动输入的数据不会显示 我的代码: ViewController.h #import <UIKit/UIKit.h> #import <QuartzCore/QuartzCore.h> @interface CallTeacherViewController : UIViewController <UITableViewDat
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
@interface CallTeacherViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UIView *topLayer;
@property (nonatomic) CGFloat layerPosition;
#导入
#进口
@接口调用TeacherViewController:UIViewController
@属性(弱、非原子)IBUIView*顶层;
@属性(非原子)CG位置;
视图控制器.m
#import "CallTeacherViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface CallTeacherViewController ()
@end
@implementation CallTeacherViewController
@synthesize topLayer = _topLayer;
@synthesize layerPosition = _layerPosition;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return 200;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
return cell;
}
-(void)viewDidLoad {
self.topLayer.layer.shadowOffset = CGSizeMake(-1,0);
self.topLayer.layer.shadowOpacity = .9;
self.layerPosition = self.topLayer.frame.origin.x;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
#define VIEW_HIDDEN 80
-(void) animateLayerToPoint:(CGFloat)x
{
[UIView animateWithDuration:0.3
delay:0
options:UIViewAnimationCurveEaseOut
animations:^{
CGRect frame = self.topLayer.frame;
frame.origin.x = x;
self.topLayer.frame = frame;
}
completion:^(BOOL finished){
self.layerPosition =self.topLayer.frame.origin.x;
}];
}
- (IBAction)toggleLayer:(id)sender {
if (self.layerPosition == VIEW_HIDDEN) {
[self animateLayerToPoint:0];
} else {
[self animateLayerToPoint:VIEW_HIDDEN];
}
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if (self.layerPosition == VIEW_HIDDEN) {
[self animateLayerToPoint:0];
} else {
[self animateLayerToPoint:0];
}
}
- (IBAction)panLayer:(UIPanGestureRecognizer*)pan {
if (pan.state == UIGestureRecognizerStateChanged) {
CGPoint point = [pan translationInView:self.topLayer];
CGRect frame = self.topLayer.frame;
frame.origin.x = self.layerPosition + point.x;
if (frame.origin.x < 0 ) frame.origin.x = 0;
self.topLayer.frame = frame;
}
if (pan.state == UIGestureRecognizerStateEnded) {
if (self.topLayer.frame.origin.x <= 81) {
[self animateLayerToPoint:0];
} else {
[self animateLayerToPoint: VIEW_HIDDEN];
}
}
}
#导入“CallTeacherViewController.h”
#进口
@接口调用TeacherViewController()
@结束
@实现CallTeacherViewController
@合成顶层=_顶层;
@合成层位置=_层位置;
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节
{
//返回节中的行数。
返回200;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“Cell”;
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
//配置单元格。。。
返回单元;
}
-(无效)viewDidLoad{
self.topLayer.layer.shadowOffset=CGSizeMake(-1,0);
self.topLayer.layer.shadowOpacity=.9;
self.layerPosition=self.topLayer.frame.origin.x;
}
-(布尔)应自动旋转指针面定向:(UIInterfaceOrientation)interfaceOrientation
{
返回YES;
}
#定义视图_隐藏80
-(void)animateLayerToPoint:(CGFloat)x
{
[UIView animateWithDuration:0.3
延迟:0
选项:UIViewAnimationCurveEaseOut
动画:^{
CGRect frame=self.topLayer.frame;
frame.origin.x=x;
self.topLayer.frame=frame;
}
完成:^(布尔完成){
self.layerPosition=self.topLayer.frame.origin.x;
}];
}
-(iAction)切换层:(id)发送方{
if(self.layerPosition==视图_隐藏){
[自动画传送点:0];
}否则{
[self-animateLayerToPoint:VIEW_HIDDEN];
}
}
-(无效)视图显示:(BOOL)动画
{
[超级视图显示:动画];
if(self.layerPosition==视图_隐藏){
[自动画传送点:0];
}否则{
[自动画传送点:0];
}
}
-(iAction)panLayer:(UIPangEstureRecognitor*)pan{
如果(pan.state==UIGestureRecognitizerStateChanged){
CGPoint=[平移视图:self.topLayer];
CGRect frame=self.topLayer.frame;
frame.origin.x=self.layerPosition+point.x;
如果(frame.origin.x<0)frame.origin.x=0;
self.topLayer.frame=frame;
}
if(pan.state==UIgestureRecognitizerStateEnded){
如果(self.topLayer.frame.origin.x如果已在情节提要中设置静态单元格的文本,则必须删除以下方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
及
及
如果从序列图像板设置静态单元格,则不需要这些方法,因为它们在序列图像板上决定:有多少个单元格以及每个单元格的文本
编辑:
如果您想要UIViewController中带有静态单元格的tableView,并且您的应用程序是iOS 6+,您可以:
在UIVIewController中添加UIContainerView,在容器视图中,可以将UITableViewController与静态单元格一起放置
如果已在情节提要中设置静态单元格的文本,则必须删除以下方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
及
及
如果从序列图像板设置静态单元格,则不需要这些方法,因为它们在序列图像板上决定:有多少个单元格以及每个单元格的文本
编辑:
如果您想要UIViewController中带有静态单元格的tableView,并且您的应用程序是iOS 6+,您可以:
在UIVIewController中添加UIContainerView,在容器视图中,可以将UITableViewController与静态单元格一起放置
如果已在情节提要中设置静态单元格的文本,则必须删除以下方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
及
及
如果从序列图像板设置静态单元格,则不需要这些方法,因为它们在序列图像板上决定:有多少个单元格以及每个单元格的文本
编辑:
如果您想要UIViewController中带有静态单元格的tableView,并且您的应用程序是iOS 6+,您可以:
在UIVIewController中添加UIContainerView,在容器视图中,可以将UITableViewController与静态单元格一起放置
如果已在情节提要中设置静态单元格的文本,则必须删除以下方法:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
及
及
如果从序列图像板设置静态单元格,则不需要这些方法,因为它们在序列图像板上决定:有多少个单元格以及每个单元格的文本
编辑:
如果您想要UIViewController中带有静态单元格的tableView,并且您的应用程序是iOS 6+,您可以:
在UIVIewController中添加UIContainerView,在容器视图中,可以将UITableViewController与静态单元格一起放置
这里将用动态tableview内容填充您的tableview。如果您确实希望通过故事板获得静态内容,请参阅Ilario答案
//h
这里是用动态的tableview内容填充你的tableview。如果你真的想通过故事板获得静态内容,请参阅Ilario答案
//h
这里是用动态的tableview内容填充你的tableview。如果你真的想通过故事板获得静态内容,请参阅Ilario答案
//h
这里是用动态的tableview内容填充你的tableview。如果你真的想通过故事板获得静态内容,请参阅Ilario答案
//h
在TableViewController
class下添加以下代码,对我有用
override func viewDidAppear(animated: Bool){
self.tableView.reloadData()
}
在TableViewController
class下添加以下代码,对我有用
override func viewDidAppear(animated: Bool){
self.tableView.reloadData()
}
加上b