Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iTableView出现在iOS 7.1上,但不出现在iOS 8.2上_Ios_Objective C_Uitableview - Fatal编程技术网

iTableView出现在iOS 7.1上,但不出现在iOS 8.2上

iTableView出现在iOS 7.1上,但不出现在iOS 8.2上,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我使用Xcode 6.2,swift和我遇到问题的这个特殊类在Objective中。我使用的是storyboard,一个tabcontroller,其中一个选项卡调用historyViewController`它有一个表视图。在iOS7中,当我单击history选项卡按钮时,表视图将显示其数据 #import "historyListViewController.h" #import "QRdatabase.h" #import "qrdbinfo.h" #import "historyDeta

我使用Xcode 6.2,swift和我遇到问题的这个特殊类在Objective中。我使用的是storyboard,一个tabcontroller,其中一个选项卡调用
historyViewController`它有一个表视图。在iOS7中,当我单击history选项卡按钮时,表视图将显示其数据

#import "historyListViewController.h"
#import "QRdatabase.h"
#import "qrdbinfo.h"
#import "historyDetailViewController.h"
#import <UIKit/UIKit.h>
#import "SDWebImage/UIImageView+WebCache.h"
#import "UIImageView+WebCache.h"
@implementation historyListViewController
@synthesize details = _details;
@synthesize qrInfos = _qrInfos;
@synthesize segmentchange;

- (IBAction)valid_in_seg:(id)sender
{
if (segmentchange.selectedSegmentIndex == 0)
{   self.qrInfos = [QRdatabase database].qrdbInfos;
[self.tablelist reloadData];

}
else
{
self.qrInfos = [QRdatabase database].inqrdbInfos;

}
[self.tablelist reloadData];

}
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];

 // Scroll table view to the last row
 if (_shouldScrollToLastRow)
 {
    _shouldScrollToLastRow = NO;
    [self.tablelist setContentOffset:CGPointMake(0, CGFLOAT_MAX)];
 }
 [self.tablelist reloadData];
}
- (void)viewDidLoad {
   [super viewDidLoad];
  [self.tablelist reloadData];
   UIImage *myImage =[UIImage imageNamed:@"logo_white_38.png"];
  UIImageView *myImageView = [[UIImageView alloc] initWithImage:myImage];
[myImageView setFrame:CGRectMake(0, 0, 38, 38)];
self.navigationItem.titleView = myImageView;
self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
segmentchange.tintColor = [UIColor redColor];

_shouldScrollToLastRow = YES;

if (segmentchange.selectedSegmentIndex == 0)
{
    self.qrInfos = [QRdatabase database].qrdbInfos;

    [self.tablelist reloadData];

}
else
{
    self.qrInfos = [QRdatabase database].inqrdbInfos;
    [self.tablelist reloadData];
}
self.tablelist.delegate = self;
self.tablelist.dataSource = self;
[self.view addSubview:self.tablelist];


}
 - (void)viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];
 if (segmentchange.selectedSegmentIndex == 0)
 {
     self.qrInfos = [QRdatabase database].qrdbInfos;
     [self.tablelist reloadData];

 }
 else
 {
     self.qrInfos = [QRdatabase database].inqrdbInfos;
     [self.tablelist reloadData];
 }

 [self.tablelist reloadData];
 }


- (void)didReceiveMemoryWarning {
 // Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
[[NSURLCache sharedURLCache] removeAllCachedResponses];

}

/*- (void)viewDidUnload {
    self.qrInfos = nil;
  self.details = nil;
 }*/


#pragma mark Table view methods
- (CGFloat)tableView:(UITableView *)tableView    heightForHeaderInSection:(NSInteger)section
{
return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{ if (segmentchange.selectedSegmentIndex == 0)
{

return 80;
}
else
    return 120;

}


 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  return 1;
 }


// Customize the number of rows in the table view
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
   return [_qrInfos count];
}


 // Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


  if (segmentchange.selectedSegmentIndex == 0)
  {
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [self.tablelist dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];}
    qrdbinfo *info = [_qrInfos objectAtIndex:indexPath.row];
    cell.textLabel.text = info.qr_code;

 cell.detailTextLabel.text = [NSString stringWithFormat:@"Date:  %@", info.date];

    CGSize itemSize = CGSizeMake(30, 30);
    UIGraphicsBeginImageContext(itemSize);
    CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
    [cell.imageView.image drawInRect:imageRect];
    cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    [cell.imageView sd_setImageWithURL:[NSURL URLWithString:info.img]
                      placeholderImage:[UIImage imageNamed:@"img_not_available.png"]];
    return cell;

 }
 else
 {
    static NSString *CellIdentifier = @"Cell2";

    UITableViewCell *cell = [self.tablelist dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }

    qrdbinfo *info = [_qrInfos objectAtIndex:indexPath.row];
           cell.textLabel.text = info.qr_code;
    cell.detailTextLabel.text = [NSString stringWithFormat:@"Date:  %@", info.date];
    return cell;

  }
 // return cell;
  }

  - (void)downloadImageWithURL:(NSURL *)url completionBlock:(void (^)(BOOL succeeded, UIImage *image))completionBlock
  {
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request
                                   queue:[NSOperationQueue mainQueue]
                       completionHandler:^(NSURLResponse *response,    NSData *data, NSError *error) {
                           if ( !error )
                           {
                               UIImage *image = [[UIImage alloc] initWithData:data];
                               completionBlock(YES,image);
                           } else{
                               completionBlock(NO,nil);
                           }
                       }];
 }


 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(segmentchange.selectedSegmentIndex == 0)
{
qrdbinfo *info = [_qrInfos objectAtIndex:indexPath.row];

UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"Main"
                                              bundle:nil];
historyDetailViewController * vc = [sb instantiateViewControllerWithIdentifier:@"detail"];

   vc.hidesBottomBarWhenPushed = YES;
vc.qrId = info.uniqueId;
[self.navigationController pushViewController:vc animated:YES];
}
else
{
    UIAlertView *alerts = [[UIAlertView alloc] initWithTitle:@" Data Unavailable" message:@"No data available for invalid scans" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil, nil];

    [alerts show];
}
               }



 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {

return YES;
}

// Override to support editing the table view.

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

 if (editingStyle == UITableViewCellEditingStyleDelete) {
 qrdbinfo *info = [_qrInfos objectAtIndex:indexPath.row];
 [self.qrInfos removeObjectAtIndex:indexPath.row];
 [self.tablelist deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];

 if(segmentchange.selectedSegmentIndex == 0)
 {
 // Delete the row from the data source

 [[QRdatabase database] deleterow:info.uniqueId];


 }
 else
 {
     [[QRdatabase database] deleteinvalidrow:info.uniqueId];
 }
 [self.tablelist reloadData ];

 }
 else if (editingStyle == UITableViewCellEditingStyleInsert) {
 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
 }
 }


@end
在iOS8中,当我单击history选项卡按钮时,表视图不会出现。如果我单击其他一些选项卡按钮,然后再次选择history选项卡按钮,表视图将正确显示其数据

#import "historyListViewController.h"
#import "QRdatabase.h"
#import "qrdbinfo.h"
#import "historyDetailViewController.h"
#import <UIKit/UIKit.h>
#import "SDWebImage/UIImageView+WebCache.h"
#import "UIImageView+WebCache.h"
@implementation historyListViewController
@synthesize details = _details;
@synthesize qrInfos = _qrInfos;
@synthesize segmentchange;

- (IBAction)valid_in_seg:(id)sender
{
if (segmentchange.selectedSegmentIndex == 0)
{   self.qrInfos = [QRdatabase database].qrdbInfos;
[self.tablelist reloadData];

}
else
{
self.qrInfos = [QRdatabase database].inqrdbInfos;

}
[self.tablelist reloadData];

}
- (void)viewDidLayoutSubviews
{
[super viewDidLayoutSubviews];

 // Scroll table view to the last row
 if (_shouldScrollToLastRow)
 {
    _shouldScrollToLastRow = NO;
    [self.tablelist setContentOffset:CGPointMake(0, CGFLOAT_MAX)];
 }
 [self.tablelist reloadData];
}
- (void)viewDidLoad {
   [super viewDidLoad];
  [self.tablelist reloadData];
   UIImage *myImage =[UIImage imageNamed:@"logo_white_38.png"];
  UIImageView *myImageView = [[UIImageView alloc] initWithImage:myImage];
[myImageView setFrame:CGRectMake(0, 0, 38, 38)];
self.navigationItem.titleView = myImageView;
self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
segmentchange.tintColor = [UIColor redColor];

_shouldScrollToLastRow = YES;

if (segmentchange.selectedSegmentIndex == 0)
{
    self.qrInfos = [QRdatabase database].qrdbInfos;

    [self.tablelist reloadData];

}
else
{
    self.qrInfos = [QRdatabase database].inqrdbInfos;
    [self.tablelist reloadData];
}
self.tablelist.delegate = self;
self.tablelist.dataSource = self;
[self.view addSubview:self.tablelist];


}
 - (void)viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];
 if (segmentchange.selectedSegmentIndex == 0)
 {
     self.qrInfos = [QRdatabase database].qrdbInfos;
     [self.tablelist reloadData];

 }
 else
 {
     self.qrInfos = [QRdatabase database].inqrdbInfos;
     [self.tablelist reloadData];
 }

 [self.tablelist reloadData];
 }


- (void)didReceiveMemoryWarning {
 // Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
[[NSURLCache sharedURLCache] removeAllCachedResponses];

}

/*- (void)viewDidUnload {
    self.qrInfos = nil;
  self.details = nil;
 }*/


#pragma mark Table view methods
- (CGFloat)tableView:(UITableView *)tableView    heightForHeaderInSection:(NSInteger)section
{
return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{ if (segmentchange.selectedSegmentIndex == 0)
{

return 80;
}
else
    return 120;

}


 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  return 1;
 }


// Customize the number of rows in the table view
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
   return [_qrInfos count];
}


 // Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


  if (segmentchange.selectedSegmentIndex == 0)
  {
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [self.tablelist dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];}
    qrdbinfo *info = [_qrInfos objectAtIndex:indexPath.row];
    cell.textLabel.text = info.qr_code;

 cell.detailTextLabel.text = [NSString stringWithFormat:@"Date:  %@", info.date];

    CGSize itemSize = CGSizeMake(30, 30);
    UIGraphicsBeginImageContext(itemSize);
    CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
    [cell.imageView.image drawInRect:imageRect];
    cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    [cell.imageView sd_setImageWithURL:[NSURL URLWithString:info.img]
                      placeholderImage:[UIImage imageNamed:@"img_not_available.png"]];
    return cell;

 }
 else
 {
    static NSString *CellIdentifier = @"Cell2";

    UITableViewCell *cell = [self.tablelist dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }

    qrdbinfo *info = [_qrInfos objectAtIndex:indexPath.row];
           cell.textLabel.text = info.qr_code;
    cell.detailTextLabel.text = [NSString stringWithFormat:@"Date:  %@", info.date];
    return cell;

  }
 // return cell;
  }

  - (void)downloadImageWithURL:(NSURL *)url completionBlock:(void (^)(BOOL succeeded, UIImage *image))completionBlock
  {
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request
                                   queue:[NSOperationQueue mainQueue]
                       completionHandler:^(NSURLResponse *response,    NSData *data, NSError *error) {
                           if ( !error )
                           {
                               UIImage *image = [[UIImage alloc] initWithData:data];
                               completionBlock(YES,image);
                           } else{
                               completionBlock(NO,nil);
                           }
                       }];
 }


 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(segmentchange.selectedSegmentIndex == 0)
{
qrdbinfo *info = [_qrInfos objectAtIndex:indexPath.row];

UIStoryboard*  sb = [UIStoryboard storyboardWithName:@"Main"
                                              bundle:nil];
historyDetailViewController * vc = [sb instantiateViewControllerWithIdentifier:@"detail"];

   vc.hidesBottomBarWhenPushed = YES;
vc.qrId = info.uniqueId;
[self.navigationController pushViewController:vc animated:YES];
}
else
{
    UIAlertView *alerts = [[UIAlertView alloc] initWithTitle:@" Data Unavailable" message:@"No data available for invalid scans" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil, nil];

    [alerts show];
}
               }



 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {

return YES;
}

// Override to support editing the table view.

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

 if (editingStyle == UITableViewCellEditingStyleDelete) {
 qrdbinfo *info = [_qrInfos objectAtIndex:indexPath.row];
 [self.qrInfos removeObjectAtIndex:indexPath.row];
 [self.tablelist deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];

 if(segmentchange.selectedSegmentIndex == 0)
 {
 // Delete the row from the data source

 [[QRdatabase database] deleterow:info.uniqueId];


 }
 else
 {
     [[QRdatabase database] deleteinvalidrow:info.uniqueId];
 }
 [self.tablelist reloadData ];

 }
 else if (editingStyle == UITableViewCellEditingStyleInsert) {
 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
 }
 }


@end
#导入“historyListViewController.h”
#导入“QRdatabase.h”
#导入“qrdbinfo.h”
#导入“historyDetailViewController.h”
#进口
#导入“SDWebImage/UIImageView+WebCache.h”
#导入“UIImageView+WebCache.h”
@historyListViewController的实现
@综合细节=_细节;
@综合qrInfos=_qrInfos;
@综合变化;
-(iAction)seg中的有效\u:(id)发送方
{
if(segmentchange.selectedSegmentIndex==0)
{self.qrInfos=[QRdatabase database].qrdbInfos;
[self.tablelist重载数据];
}
其他的
{
self.qrInfos=[QRdatabase database].inqrdbInfos;
}
[self.tablelist重载数据];
}
-(无效)ViewDidLayoutSubView
{
[超级视图布局子视图];
//将表格视图滚动到最后一行
如果(_shoulldtolastrow)
{
_shoulldScrollTolastrow=否;
[self.tablelist setContentOffset:CGPointMake(0,CGFLOAT_MAX)];
}
[self.tablelist重载数据];
}
-(无效)viewDidLoad{
[超级视图下载];
[self.tablelist重载数据];
UIImage*myImage=[UIImage ImageName:@“logo_white_38.png”];
UIImageView*myImageView=[[UIImageView alloc]initWithImage:myImage];
[myImageView设置帧:CGRectMake(0,0,38,38)];
self.navigationItem.titleView=myImageView;
self.navigationController.navigationBar.backgroundColor=[UIColor redColor];
segmentchange.tintColor=[UIColor redColor];
_shoulldScrollTolastrow=是;
if(segmentchange.selectedSegmentIndex==0)
{
self.qrInfos=[QRdatabase database].qrdbInfos;
[self.tablelist重载数据];
}
其他的
{
self.qrInfos=[QRdatabase database].inqrdbInfos;
[self.tablelist重载数据];
}
self.tablelist.delegate=self;
self.tablelist.dataSource=self;
[self.view addSubview:self.tablelist];
}
-(无效)视图显示:(BOOL)动画{
[超级视图显示:动画];
if(segmentchange.selectedSegmentIndex==0)
{
self.qrInfos=[QRdatabase database].qrdbInfos;
[self.tablelist重载数据];
}
其他的
{
self.qrInfos=[QRdatabase database].inqrdbInfos;
[self.tablelist重载数据];
}
[self.tablelist重载数据];
}
-(无效)未收到记忆警告{
//如果视图没有superview,则释放该视图。
[超级记忆警告];
[[NSURLCache sharedURLCache]移除所有缓存响应];
}
/*-(无效)视图卸载{
self.qrInfos=nil;
self.details=nil;
}*/
#pragma标记表视图方法
-(CGFloat)表格视图:(UITableView*)表格视图头部高度部分:(NSInteger)部分
{
返回10;
}
-(CGFloat)tableView:(UITableView*)表视图行高度索引路径:(NSIndexPath*)索引路径
{如果(segmentchange.selectedSegmentIndex==0)
{
返回80;
}
其他的
返回120;
}
-(NSInteger)表格视图中的节数:(UITableView*)表格视图{
返回1;
}
//自定义表视图中的行数
-(NSInteger)表视图:(UITableView*)表视图行数节:(NSInteger)节{
返回[_qrinfoscount];
}
//自定义表格视图单元格的外观。
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
if(segmentchange.selectedSegmentIndex==0)
{
静态NSString*CellIdentifier=@“Cell”;
UITableViewCell*单元格=[self.tablelist dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil){
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle重用标识符:CellIdentifier];}
qrdbinfo*info=[\u qrInfos objectAtIndex:indexath.row];
cell.textlab.text=info.qr\u码;
cell.detailTextLabel.text=[NSString stringWithFormat:@“日期:%@”,info.Date];
cgsizeitemsize=CGSizeMake(30,30);
UIGraphicsBeginImageContext(itemSize);
CGRect imageRect=CGRectMake(0.0,0.0,itemSize.width,itemSize.height);
[cell.imageView.image drawInRect:imageRect];
cell.imageView.image=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsSendImageContext();
[cell.imageView sd_setImageWithURL:[NSURL URLWithString:info.img]
占位符图像:[UIImage ImageName:@“img_not_available.png”];
返回单元;
}
其他的
{
静态NSString*CellIdentifier=@“Cell2”;
UITableViewCell*单元格=[self.tablelist dequeueReusableCellWithIdentifier:CellIdentifier];
如果(单元格==nil){
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle重用标识符:CellIdentifier];
}
qrdbinfo*info=[\u qrInfos objectAtIndex:indexath.row];
cell.textlab.text=info.qr\u码;
cell.detailTextLabel.text=[NSString stringWithFormat:@“日期:%@”,info.Date];
返回单元;
}
//返回单元;
}
-(void)下载带有url的图像:(NSURL*)url完成块:(void(^)(BOOL成功,UIImage*image))完成块
{
NSMutableURLRequest*请求=[NSMutableUrlRequestRequestWithURL:url];
[NSURLConnection sendAsynchronousRequest:请求
队列:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse*响应,NSData*数据,NSError*错误){
如果(!错误)
{
UIImage*image=[[UIImage alloc]initWithData:data];
completionBlock(是,图像);
}否则{
完井区块(无,无);
}
}];
}
-(void)tableView:(UITableView*)tableView未选择Rowatindexpath