小编Ben*_*Ben的帖子

UINavigationController popToRootViewController,然后立即推送一个新视图

我有一个带有两个选项卡的tabBarController,其中第一个包含NavigatorController的实例.navigatorController是使用自定义viewController"peersViewController"启动的,它列出了tableView上的所有网络对等体.选择对等体后,"FilesListViewController"(将c:\目录中的列表文件)的实例推送到navigationController堆栈中.

在这个filesListViewController中我有一个按钮让它导航到说文档目录.为此,我连接了接口以在rootViewController中调用gotoDirectory:(NSString*)路径方法:

- (void)gotoDirectory:(NSString*)path {
     [[self navigationController] popToRootViewControllerAnimated:YES];
     NSArray *files = [self getFilesFromPeerAtPath:path];
     FilesListViewController *filesVC = [[FilesListViewController alloc] initWithFiles:files];
     [[self navigationController] pushViewController:filesVC animated:YES];
     [filesVC release];
}
Run Code Online (Sandbox Code Playgroud)

但是,当我按下该按钮时,navigationController确实将我的视图弹出到根视图控制器,但是我实例化的FilesListViewController没有出现.从日志中,我知道确实调用了自定义initWithFiles方法,并且确实发生了网络内容以获取文件名.

关于此,还有其他一些问题.我尝试点击第二个标签,然后点击返回第一个标签,然后点击!我需要的文件名就在那里.看起来数据和filesListViewController确实被推入了navigatorController堆栈,但显示没有刷新,而是停留在rootViewController(peersViewController)的屏幕上.

我做错了吗?

--Ben.

- 在发布问题后15分钟编辑.我找到了一个解决方法,但是让我困扰的是pop然后推不起作用.

- (void)gotoDirectory:(NSString*)path {
     PeersListViewController *rootViewController = (PeersListViewController*)[[[self navigationController] viewControllers] objectAtIndex:0];
     [[self navigationController] setViewControllers:[NSArray arrayWithObject:rootViewController]];
     FilesListViewController *filesVC = [[FilesListViewController alloc] initWithFiles:files];
     [[self navigationController] pushViewController:filesVC animated:YES];
     [filesVC release];
}
Run Code Online (Sandbox Code Playgroud)

似乎应该以这种方式规避navigationController,我可能不得不释放原始堆栈中的所有viewControllers.但这确实适用于iphone 3.0模拟器.

如果我正在使用此代码,应如何处理内存释放?我应该获得原始的NSArray视图控制器并释放所有内容吗?

iphone uinavigationcontroller

23
推荐指数
2
解决办法
4万
查看次数

我应该继续在自动参考计数(ARC)下使用iVar和@property(非原子,保留)加@synthesize吗?

就像一个doop我已经在接口.h文件中声明了Instant Variables(iVar)然后@property一段时间了.

@interface MainGameViewController : UIViewController {
     UserFactorsViewController *userFactorsViewController;
     UITableView *myTableView;
}
@property (nonatomic, retain) UserFactorsViewController *userFactorsViewController;
@property (nonatomic, retain) IBOutlet UITableView *myTableView;
Run Code Online (Sandbox Code Playgroud)

在自动引用计数下,我应该省去iVar并全部使用@property吗?我是否应该在财产中使用"保留"一词?如果我正在部署iOS 4.3,我还应该使用ARC吗?

ios xcode4 ios5 automatic-ref-counting

9
推荐指数
1
解决办法
6383
查看次数

iPhone SDK使用Quartz缩放和刷新PDF

查看QuartzDemo示例应用程序,我喜欢单独使用quartz(即不使用uiwebview)的PDF rending速度.但是,当我放大PDF时,它似乎不像在PDF视图中那样变得更加清晰.

在使用多点触控放大和缩小时,有什么东西可以改变以产生相同的效果吗?喜欢操纵PDF转换矩阵或什么?

谢谢一堆.

--Ben

iphone quartz-graphics

5
推荐指数
1
解决办法
3578
查看次数

为什么initWithRootViewController不保留传递给它的viewController类?

我有一个名为SourceListViewController的自定义viewController,我将它添加到UINavigationController中,然后将其视图添加到iphone App的窗口中.在将SourceListViewController传递给UINavigationController之后,我发布了sourceListViewController.

SourceListViewController *sourceListVC = [[SourceListViewController alloc] initWithNibName:@"SourceListViewController" bundle:nil];
UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:sourceListVC] autorelease];
[sourceListVC release];
Run Code Online (Sandbox Code Playgroud)

当我这样做时,应用程序会在视图加载到手机后崩溃.当我注释掉最后一行时,应用程序正常工作.是不是initWithRootViewController应该保留sourceListVC的副本?

iphone uinavigationcontroller

1
推荐指数
1
解决办法
2844
查看次数