- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个导航 Controller ,它是我应用程序的 Root View Controller 。这是我的主屏幕。我有一个 Split View Controller ,其主视图列出了位置,详细 View 显示了 map 上的位置。我想将 Split View Controller 推送到导航 Controller ,但它抛出一个错误,指出 Split View Controller 无法推送到导航 Controller ,它必须是应用程序的 Root View Controller 。所以我努力尝试。
MyAppDelegate *myappdelegate= [[UIApplication sharedApplication] delegate];
UISplitViewController * vc= [[UISplitViewController alloc] init];
vs.viewControllers = [NSArray arraywithObjects......
....
myappdelegate.window.rootViewController= vc;
这行得通。它按预期显示没有动画的 Split View Controller 。当我关闭 Split View Controller 时,我执行相同的步骤。我正在创建一个带有主屏幕 Nib 的导航 Controller ,并再次设置我的应用程序委托(delegate)的 window.rootviewController。它再次成功加载主屏幕。
但我怀疑这是实现这一目标的正确方法。有没有更合适的方式来做到这一点?
而且我无法释放 Split View Controller 的子 Controller 。我在我的子 Controller 释放方法上做了一个断点。它没有被捕获。我假设当我将我的应用程序的 Root View Controller 设置为导航 Controller 时,旧的 Root View Controller ( Split View Controller )必须与其 subview 一起发布。然后我在关闭 Split View Controller 时尝试了以下代码。
UISplitViewController *oldviewcontroller= (UISplitViewController*) myappdelegate.window.rootViewController;
for (UIViewController *child in oldviewcontroller.viewControllers)
{
[child release];
}
//Setting the navigation controller as window.rootviewController again in here.
此代码抛出错误“[UIImageView __viewDidDisappear:]:无法识别的选择器已发送至实例 0x7d...”
我认为因为已经释放 View ,viewdidDisappear 事件上没有 ImageView 。
简而言之,我的问题是我是否使用了正确的方法来实现这一目标?如果是这样,我如何才能成功释放所有 subview Controller ?
最佳答案
终于找到方法了。我可能发现了错误。我所做的就是砍掉我坐的 Twig 。我正在释放我目前所在的 View Controller :) 当调用 viewdidDisappear 时,没有这样的 View Controller 。因为我已经把它扔到太空了。下面是我的工作步骤。我希望它对某人有用。但我无法忍受苹果可能会拒绝我的应用程序。我希望找到一个合适的方法。
这是我交替使用 Split View Controller 和导航 Controller 作为窗口 Root View Controller 的最终工作方式。
首先,我在 AppDelegate 接口(interface)中定义了 NavigationController 和 SplitViewController 属性。
AppDelegate.h
@property (assign,nonatomic) UINavigationController * NC;
@property (assign,nonatomic) UISplitViewController *SVC;
其次,我在 AppDelegate didFinishLaunch 事件上分配新创建的 NC。
AppDelegate.m
//Creating my main screen controller
//Creating my navigation controller with my view controller instance. Then
self.NC= my_navigation_controller;
self.window.rootViewController= self.NC;
第三次创建一个splitview controller并设置为app的root view controller
MyMainScreen.m
-(void) OpenSplit()
{
//Creating my master view controller of SVC
//Creating my detail view controller of SVC
//Creating my SVC;
AppDelegate * app_delegate= [[UIApplication sharedApplication] delegate];
app_delegate.SVC= newly created my SVC;
app_delegate.window.rootViewController= app_delegate.SVC;
}
第四,在SVC详情 View 的viewDidLoad事件中释放未使用的NC。
MyDetailView.m
- (void) viewDidLoad()
{
...
AppDelegate * app_delegate= [[UIApplication sharedApplication] delegate];
app_delegate.NC= nil; //i dont need it now. i am releasing. Releasing Navigation Controller release as well child controllers. I learned with testing.
}
第五,管理关闭 Split View功能。我在 DetailView 的 NavigationBar 上使用了 UIBarButton。
MyDetailView.m
-(void) closeSplitView
{
//Creating navigation controller with my main screen view controller
AppDelegate * app_delegate= [[UIApplication sharedApplication] delegate];
app_delegate.NC= newly_created_NC;
app_delegate.window.rootViewController= appdelegate.NC;
}
第六处理主屏幕 viewDidLoad 事件中未使用的 Split View Controller 。
MyMainScreen.m
-(void) viewDidLoad
{
AppDelegate * app_delegate= [[UIApplication sharedApplication] delegate];
app_delegate.SVC= nil; //I am releasing it because i am working with NC now.
}
关于ios - 交替使用 Split View Controller 和 Navigation Controller 作为 Window Root View Controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13685828/
在 R 中,您可以使用 strsplit在分隔符( split )上分割向量的函数如下: x <- "What is this? It's an onion. What! That's| Well
我的 .split(); 方法有问题。 我称这个函数为: get_content_ajax("html/settings.html", "#ajax", 1, "Settings page have
我是Elixir的新手。我正在尝试对字符串split的基本操作,如下所示 String.split("Awesome",""); 根据elixir document,它应该根据提供的模式split字符
当我使用 =arrayformula(split(input!G2:G, ",")) 时,为什么拆分公式没有扩展到整个列? 我只得到输入的结果!G2 单元格,而不是 G 列中的其余部分。其他公式如 =
我正在尝试制作一个名为 core-splitter 的元素,该元素在 1.0 中已弃用,因为它在我们的项目中起着关键作用。 如果您不知道 core-splitter 的作用,我可以提供一个简短的描述。
我很难尝试使用多个定界符将字符串拆分为列表。我可以像下面这样将它拆分两次: myString.split(':')[1].split('.') 然而,这看起来很不优雅。在我的脑海里,我想做这样的事情:
来自使用惊喜模块的推荐引擎的代码,我在任何地方都找不到答案。 最佳答案 根据您的目标,您可以使用 cross_validation方法,它将自动为您执行拆分。示例:cross_validate(alg
我正在制作一个有丝 split 模拟器,我希望它在细胞足够大并 split 时运行有丝 split 功能。当它分割时,我希望它能够将分割从初始 x 值(前一个单元格的 x)动画化为新的 x 值(右侧的
我有一个用于三个按钮的点击处理程序,在这个处理程序中我想提取所点击按钮的 ID。我有一行这样的代码: $('#switch button').click(function(){ var cla
我需要像这样分割一个字符串 var val = "$cs+55+mod($a)"; 放入数组 arr = val.split( /[+-/*()\s*]/ ); 问题是将分隔符保留为数组元素,如 ar
我在同一个 string 上使用 split() 和 split("") .但为什么 split("") 返回的元素数量少于 split()?我想知道在什么特定的输入情况下会发生这种情况。 最佳答案
我的代码中某处有错误,但看不到我做错了什么。 我拥有的是 facebook 用户 ID 的隐藏输入,它是通过 jQuery UI 自动完成填充的: 然后,我有一个 jQuery 函数,当单击链接将其
我正在寻找一个程序来读取字符串/文件并显示其中的前三个单词。 所以我尝试了: letter= "a,b,c" print(letter.split(',')[0]) 这对获取一个单词有效,但执行 [0
我有一个存储邮件的表 Mails(谁会想到... ;))。 通过 tinyint MailStatus,我决定这是 SentMail、Draft 还是 ReceivedMail。 现在我想知道 Tab
在我的优化探索中,我发现内置的 split() 方法比等效的 re.split() 方法快大约 40%。 虚拟基准(易于复制粘贴): import re, time, random def rando
我对split有一个奇怪的问题,因为默认情况下它不会将split放入默认数组中。 以下是一些玩具代码。 #!/usr/bin/perl $A="A:B:C:D"; split (":",$A); pr
我目前正在学习 JCL,并且正在使用 SORT 程序。作为练习,我想将一些输入记录拆分为属于同一 PDS 的多个成员。这是我的 JCL 代码: //FAILJ JOB //STEP1 EX
在苦苦挣扎了半小时之后,我在使用空格分割字符串时遇到了这种差异,具体取决于您使用的语法。 简单字符串: $line = "1: 2: 3: 4: 5: " 拆分示例1 -从1开始注意带有 token
我有一个像这样的字符串: 'Agendas / Schedules meetings and speakers 4 F 1928-1209 Box 2' 我正在尝试将其
我试图了解 r-tree 的工作原理,发现有两种类型的拆分:二次拆分和线性拆分。 线性和二次实际上有什么区别?在哪种情况下,一个会比另一个更受欢迎? 最佳答案 原始 R-Tree 论文在 3.5.2
我是一名优秀的程序员,十分优秀!