拿了一个简单的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

...全文
291 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
内容概要:本文围绕基于蜣螂优化算法(DBO)的无线传感器网络(WSN)覆盖优化问题展开研究,提出了一种创新性的智能优化解决方案,并提供了完整的Matlab代码实现。研究首先分析了传统WSN覆盖优化中存在的覆盖率低、能耗不均等问题,随后引入蜣螂优化算法这一新型群体智能算法,通过模拟蜣螂的生物行为机制,构建了适用于传感器节点部署优化的数学模型。文中详细阐述了算法的设计思路、实现步骤及其在提高网络覆盖率、延长网络生命周期方面的有效性,同时通过仿真实验与其他主流优化算法进行了对比,验证了所提方法的优越性。; 适合人群:具备一定优化算法基础和Matlab编程能力,从事通信工程、物联网、智能优化等相关领域的研究生及科研人员。; 使用场景及目标:①解决无线传感器网络中节点部署不合理导致的覆盖盲区问题;②提升网络整体覆盖性能与资源利用效率;③为智能优化算法在实际工程中的应用提供可复现的研究案例和技术参考。; 阅读建议:建议读者结合文中的Matlab代码进行实践操作,重点关注算法参数设置、适应度函数设计及仿真结果分析部分,同时可尝试将该算法迁移至路径规划、资源调度等其他优化场景中进行拓展研究。
已经博主授权,源码转载自 https://pan.quark.cn/s/a4b39357ea24 在信息技术领域,特别是软件编程行业,微软公司推出的集成开发环境(IDE)Visual Studio,凭借其卓越的功能和广泛的适用范围,成为了众多程序员的常用工具。不过,在实际操作期间,用户可能会遭遇各种挑战,其中一种较为普遍的挑战是“Visual Studio遭遇了异常情况,这或许与某个附加组件有关”。本文将详细研究这一现象的成因、潜在后果以及最终的应对措施。 ### 原因剖析 Visual Studio通过支持多种插件和附加组件来扩展其功能,这些组件通常由第三方开发者设计,旨在为用户提供更多个性化和专业化的工具。然而,这些插件的质量良莠不齐,部分可能未经过充分的测试或与特定版本的Visual Studio存在兼容性难题,从而在执行时引发异常。异常的出现可能源于以下几个因素: 1. **代码缺陷**:若附加组件中的代码存在逻辑问题或资源管理不当,就可能导致运行时异常。 2. **资源竞争**:多个插件同时占用相同的资源(例如内存、文件句柄等),可能会产生资源冲突,进而触发异常。 3. **依赖不匹配**:插件可能需要特定版本的库或框架,如果系统中安装的版本不一致,也可能导致异常。 4. **安全隐患**:部分插件可能存在安全漏洞,一旦被恶意利用,可能会导致更严重的问题,包括但不限于异常崩溃。 ### 后果分析 当Visual Studio遇到由附加组件引发的异常时,不仅会中断当前的工作进程,降低开发效能,还可能带来以下潜在风险: 1. **数据遗失**:若异常发生在保存操作之前,可能会导致未保存的工作内容遗失。 2. **稳定性减弱**:频繁的异常会导致Visual Stud...

29,039

社区成员

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

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