首页 \ 问答 \ 将故事板控制器复制并粘贴到xib文件中。(Copy and paste storyboard controller into xib file. Supported or not?)

将故事板控制器复制并粘贴到xib文件中。(Copy and paste storyboard controller into xib file. Supported or not?)

我想将故事板控制器重构为单独的xib,以获得更好的可重用性。 控制器扩展了UITableViewController。

我可以在故事板中选择控制器,点击Cmd-C,使用New File向导创建一个空的xib文件,最后将控制器粘贴到xib中。

它似乎工作正常。 UI元素在那里,插座就在那里等。它忘记了方向和大小(肖像,Retina 4英寸),但我可以在xcode中右侧的属性窗格中轻松设置它。

但是,当尝试使用此xib时,我收到错误消息:

加载“MyController”笔尖但未设置视图插座。

当我尝试将文件所有者连接到表视图(这是从UITableViewController扩展的控制器中的顶视图)时,xcode将不允许我连接它们。

我的问题: 是否不支持将控制器从故事板复制粘贴到xib?


I want to refactor out a storyboard controller to a separate xib, for better reusablity. The controller extends UITableViewController.

I can select the controller in the storyboard, hit Cmd-C, create an empty xib file using the New File wizard, and finally paste the controller into the xib.

It seems to work ok. The UI elements are there, the outlets are there, etc. It forgets the orientation and the size (portrait, Retina 4-inch), but I can easily set that in the properties pane to the right in xcode.

However when trying to use this xib I get a crash with error message:

loaded the "MyController" nib but the view outlet was not set.

When I try to connect Files Owner to the table view (which is the top view in a controller extended from UITableViewController), xcode won't let me connect them.

My question: Is it unsupported to copy-paste a controller from a storyboard to a xib?


原文:https://stackoverflow.com/questions/22305536
更新时间:2023-09-12 18:09

最满意答案

在Python 2.7.x中,时间增量有一个方法total_seconds来实现这个目的:

import datetime

startTime = datetime.datetime.now() - datetime.timedelta(hours=2)
endTime = datetime.datetime.now() + datetime.timedelta(hours=4)

rest = endTime - datetime.datetime.now()
total = endTime - startTime
print "left: {:.2%}".format(rest.total_seconds()/total.total_seconds())

在Python 3.2中,您可以直接划分时间增量(不经过total_seconds)。

Python 2.6.5中也注意到了这一点:将timedelta与timedelta分开 。)


In Python 2.7.x, time delta has a method total_seconds to achieve this:

import datetime

startTime = datetime.datetime.now() - datetime.timedelta(hours=2)
endTime = datetime.datetime.now() + datetime.timedelta(hours=4)

rest = endTime - datetime.datetime.now()
total = endTime - startTime
print "left: {:.2%}".format(rest.total_seconds()/total.total_seconds())

In Python 3.2, you can apparently divide the time deltas directly (without going through total_seconds).

(This has also been noted in Python 2.6.5: Divide timedelta with timedelta.)

相关问答

更多
  • 两次之间的差异,实际上无法转换为百分比。 这只是一段时间。 为了弄清楚完成的百分比,你需要知道整个目标应该花多长时间(我估计估计的时间。)然后你可以计算出这样的百分比: ElapsedTime / TotalTime * 100 总时间将是End Date - Start Date , now - start date是经过的时间now - start date 。 不是使用字符串函数来操作日期,而是使用DateTime函数会更好。 $startDate = '08/01/2015 12:00:00'; ...
  • 根据文档 ,moment.js可以解析日期字符串的格式。 尝试解析这样的日期: moment(record_time.data('date')); According to the docs, moment.js can parse that format of date string. Try to parse the date like this instead: moment(record_time.data('date'));
  • 请检查计算已经过去一天的百分比的公式。 percentage = (secondsSinceMidnight * 100) / 60; 对我来说似乎不对。 应该是这样的 percentage = 100 * secondsSinceMidnight / totalSecondsInDay; totalSecondsInDay可以是secondsSinceMidnight和secondsSinceMidnight的总和 Please check the formula for calc ...
  • 在Python 2.7.x中,时间增量有一个方法total_seconds来实现这个目的: import datetime startTime = datetime.datetime.now() - datetime.timedelta(hours=2) endTime = datetime.datetime.now() + datetime.timedelta(hours=4) rest = endTime - datetime.datetime.now() total = endTime - sta ...
  • 如果你想把你的矢量分成10个矢量,每个矢量大约占总矢量的10%,你可以像这样分割它。 N=10; splits = round(linspace(1,length(time),N+1)); t={}; for ct = 1:length(splits)-1 t{ct} = time(splits(ct):splits(ct+1)); end If you want to split your vector into 10 vectors, each about 10% of the total v ...
  • 我假设您将开始和结束时间存储为unixtimestamp。 基本上你需要做的就是计算经过的秒数与总秒数的百分比。 所以类似于: $total_secs = $end_time - $start_time; $elapsed_secs = time() - $start_time; $percent = round(($elapsed_secs/$total_secs)*100); I'll assume you're storing the start and end times as a unixt ...
  • 转换为对数域(因此您应该得到一条直线,尽管有异常值),然后应用线性回归 。 Convert to the log-domain (so that you should get a straight line, outliers notwithstanding), and then apply linear regression.
  • 您可以使用.total_seconds()从timedelta获取秒数并使用它。 >>> from datetime import timedelta >>> td1 = timedelta(1) >>> td2 = timedelta(2) >>> td1.total_seconds() / td2.total_seconds() # should give me 0.5 0.5 >>> td2 = timedelta(days=4, minutes=50) >>> td1.total_seconds() ...
  • 您可以在每个日期使用.getTime()来计算百分比: double start = (double)StartDate.getTime(); double end = (double)EndDate.getTime(); double cur = (double)CurrentDate.getTime(); double percent = ((cur - start) / (end - start)) * 100f; 编辑:添加* 100f因为它是一个百分比,而不是十进制... You can ca ...
  • 仔细研究算法后,结果表明最小成本路径总是位于矩阵的对角线上。 这意味着我上面建议的用于计算相似性百分比的修改将不起作用。 After carefully studying the algorithm, it turned out that minimum cost path will always lie on the diagonal of the matrix. This means that the modification I suggested above for calculating the ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)