拿了一个简单的tableviewController,每次已启动就崩掉,谁能帮忙看看?在线等待!

xws103 2017-04-27 04:48:27
UIViewController* rootViewCtrl = [[[UIApplication sharedApplication] keyWindow] rootViewController] ;

NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject];

IJKDemoLocalFolderViewController *viewController = [[IJKDemoLocalFolderViewController alloc] initWithFolderPath:documentsPath];

// IJKDemoLocalFolderViewController* fileManagerVc = [[IJKDemoLocalFolderViewController alloc] init];

[rootViewCtrl presentViewController:viewController animated:NO completion:nil];

以上是调用
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

/*
* Copyright (C) 2015 Gdier
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#import "IJKDemoLocalFolderViewController.h"
#import "IJKMoviePlayerViewController.h"

@interface IJKDemoLocalFolderViewController ()

@end

@implementation IJKDemoLocalFolderViewController {
NSString *_folderPath;
NSMutableArray *_subpaths;
NSMutableArray *_files;
}

- (instancetype)initWithFolderPath:(NSString *)folderPath {
self = [super init];
if (self) {
folderPath = [folderPath stringByStandardizingPath];
self.title = [folderPath lastPathComponent];

_folderPath = folderPath;
_subpaths = [NSMutableArray array];
_files = [NSMutableArray array];
}
return self;
}

- (void)viewDidLoad {
[super viewDidLoad];

NSError *error = nil;
BOOL isDirectory = NO;
NSArray *files = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:_folderPath error:&error];

[_subpaths addObject:@".."];

for (NSString *fileName in files) {
NSString *fullFileName = [_folderPath stringByAppendingPathComponent:fileName];

[[NSFileManager defaultManager] fileExistsAtPath:fullFileName isDirectory:&isDirectory];
if (isDirectory) {
[_subpaths addObject:fileName];
} else {
[_files addObject:fileName];
}
}
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
switch (section) {
case 0:
return _subpaths.count;

case 1:
return _files.count;

default:
break;
}

return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"abc"];
if (nil == cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"abc"];
cell.textLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
}

switch (indexPath.section) {
case 0: {
cell.textLabel.text = [NSString stringWithFormat:@"[%@]", _subpaths[indexPath.row]];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
} break;
case 1: {
cell.textLabel.text = _files[indexPath.row];
cell.accessoryType = UITableViewCellAccessoryNone;
} break;
default:
break;
}

return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];

switch (indexPath.section) {
case 0: {
NSString *fileName = [_folderPath stringByAppendingPathComponent:_subpaths[indexPath.row]];

IJKDemoLocalFolderViewController *viewController = [[IJKDemoLocalFolderViewController alloc] initWithFolderPath:fileName];

[self.navigationController pushViewController:viewController animated:YES];
} break;
case 1: {
NSString *fileName = [_folderPath stringByAppendingPathComponent:_files[indexPath.row]];

fileName = [fileName stringByStandardizingPath];

[IJKVideoViewController presentFromViewController:self withTitle:[NSString stringWithFormat:@"File: %@", fileName] URL:[NSURL fileURLWithPath:fileName] completion:^{
}];

} break;
default:
break;
}
}

/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
} 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
}
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the item to be re-orderable.
return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/

@end

...全文
257 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
经常使用电脑可能也遇到过了! 突然‘咚’的一声 提示 内存不能为read 这个问题我以前也遇到过不知道怎么解决 现在终于有办法了!呵呵! 我们就看看是什么原因引起的吧,另外附送一个小工具修复见下面附件 总结下大概以下9个原因 1、驱动不稳定,与系统不兼容,这最容易出现内存不能为 Read 或者文件保护(主要原因) 2、系统安装了一个或者多个流氓软件,这出现 IE 或者系统崩溃的机会也比较大,也有可能出现文件保护 3、系统加载的程序或者系统正在运行的程序之前有冲突,尤其是部分杀毒软件监控程序 4、系统本身存在漏洞,导致容易受到网络攻击。 5、病毒问题也是主要导致内存不能为 Read、文件保护、Explorer.exe 错误…… 6、如果在玩游戏时候出现内存不能为 Read,则很大可能是显卡驱动不适合(这里的不适合有不适合该游戏、不适合电脑的显卡)也有可能是 系统版本不够新或者不符合该游戏、显卡驱动 7、部分软件本身自身不足的问题 8、电脑硬件过热,也是导致内存不能为 Read 的原因之一。 9、电脑内存与主板兼容性不好也是导致内存不能为 Read 的致命原因! 以上大概就是目前可以引起系统提示 内存不能为read的原因了 另外软件是针对只是针对部分原因引起的内存不为read所做修复,不是100%有效,大家可以试试看 说下原理: 就是批处理使用 regsvr32命令 将动态链接库文件重新注册 (system32下的所有 .dll 和 .ocx 文件;) 注意:由于修复工具会重新注册 system32下的所有 .dll 和 .ocx 文件 此操作对杀毒软件来说属于敏感操作,所以建议使用修复工具的时候,请禁用杀毒软件,以免部分杀毒误报!jie

29,041

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧