因此,在将视图控制器推送到tableView后立即执行,
// Override to support row selection in the table view.
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here --
// for example, create and push another view controller.
AnotherViewController *anotherViewController =
[[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
[self.navigationController pushViewController:anotherViewController animated:YES];
好的,这样可以打开另一个视图,然后您可以通过单击导航栏左上角自动显示的按钮返回上一个视图("弹出"当前视图).
好的,所以说我想用DONE按钮填充导航栏的右侧,就像iPhone附带的"Notes"应用程序一样.我该怎么办?
我试过这样的代码:
UIBarButtonItem * doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector( doneFunc ) ]; self.navigationController.navigationItem.rightBarButtonItem = doneButton ; // not it.. [doneButton release] ;
已定义doneFunc,并且所有内容,只是按钮永远不会出现在右侧..
当我在OpenGL 2.0中更新iOS上的顶点数组时,原始顶点数据停留在屏幕上 - 即第一次刷新是持久的(我向下发送到GPU的初始点集每帧渲染),但是第二次,第3,第4,...第n次冲洗似乎都覆盖了相同的记忆.
所以我在做:
vector<VertexType> rawDynamicData ;
glGenVertexArraysOES( 1, &va ) ; CHECK_GL ;
glBindVertexArrayOES( va ) ; CHECK_GL ;
glGenBuffers( 1, &vb ) ; CHECK_GL ;
glBindBuffer( GL_ARRAY_BUFFER, vb ) ; CHECK_GL ;
glBufferData( glBufferData(
GL_ARRAY_BUFFER, //Specifies the target buffer object.
rawDynamicData.size() * sizeof( VertexType ),
&rawDynamicData[0],
GL_DYNAMIC_DRAW // I plan to update the data every frame
) ; CHECK_GL ;
Run Code Online (Sandbox Code Playgroud)
在随后的帧中,我只是再次打电话:
// update the data
glBufferData( glBufferData(
GL_ARRAY_BUFFER, //Specifies the target buffer object.
rawDynamicData.size() * sizeof( VertexType …Run Code Online (Sandbox Code Playgroud) 这个问题只是为了让我更好地理解C++中的静态变量.
我认为如果它被声明为静态,我可以在C++中返回对局部变量的引用,因为变量应该在函数返回后生效.为什么这不起作用?
#include <stdio.h>
char* illegal()
{
char * word = "hello" ;
return word ;
}
char* alsoNotLegal()
{
static char * word = "why am I not legal?" ;
return word ;
}
int main()
{
// I know this is illegal
//char * ill = illegal();
//ill[ 0 ] = '5' ;
//puts( ill ) ;
// but why is this? I thought the static variable should "live on" forever -
char * leg = alsoNotLegal() ; …Run Code Online (Sandbox Code Playgroud) 我使用Xcode .xcdatamodel文件编辑器设置了一个实体.我创建了一个名为Person的实体,添加了一些属性,然后生成了一个.m文件来表示它.一切正常.
现在当我去编写一行代码时:
Person * person = (Person*)[NSEntityDescription
insertNewObjectForEntityForName:@"Person"
inManagedObjectContext:managedObjectContext];
我得到:
由于未捕获的异常'NSInternalInconsistencyException'而终止应用程序,原因:'+ entityForName:无法找到实体名称'Person'的NSManagedObjectModel
我完全按照位置示例,我相信一步一步,但我认为我必须错过某种关键的"注册"步骤,我告诉Xcode我的Person实体应该是可访问的.而且我没有根本就是"初始化"managedObjectContext的方法,Location示例似乎也没有这样做.
所以,我正在使用FMOD api,它确实是一个C api.
不是那个坏或什么的.它只是它与C++代码没有良好的接口.
例如,使用
FMOD_Channel_SetCallback( channel, callbackFunc ) ;
Run Code Online (Sandbox Code Playgroud)
它想要一个C风格的函数callbackFunc,但我想传递一个类的成员函数.
我最终使用Win32技巧,使成员函数静态.然后它作为FMOD的回调.
现在我必须破解我的代码以使一些成员静态,只是为了解释FMOD的C-ness.
我想知道它是否可能在FMOD中或者是否有解决方法将回调链接到特定C++对象的实例成员函数(不是静态函数).它会更顺畅.
使用XCode 4.6在Mac OS X上测试.
此示例代码显示std::list正如我所期望的那样删除工作的最后一个元素:迭代器引用list::end()仍然是"1结束"并且仍然有效,即使删除了最后一个元素.
但第二个例子反驳了我的直觉.删除列表的第一个元素会发生变化list::rend(),我认为这是"从头开始".
我的期望是错的吗?为什么这是错的?为什么通过删除最后一个元素引用"1结束"仍然有效(如果不是?),但.rend()删除前元素后对"1(在开头()前面"的引用变为无效?
void printList( list<int>& os )
{
for( int& i : os )
printf( "%d ", i ) ;
puts("");
}
void testList()
{
list< int > os ;
os.push_back( 1 ) ;
os.push_back( 2 ) ;
os.push_back( 3 ) ;
os.push_back( 4 ) ;
os.push_back( 5 ) ;
// Forward iterators: reference to .end() not invalidated when remove last elt. …Run Code Online (Sandbox Code Playgroud) 好的,我们今天没有过好日子.
当您将正确的tzinfo对象附加到日期时间实例,然后strftime()它,它仍然以UTC格式出现,似乎忽略了我附加到它的漂亮的tzinfo对象.
# python 2.5.4
now = datetime.now()
print now.strftime( "%a %b %d %X" ) # %X is "locale's appropriate time rep"
pst = now.replace( tzinfo=Pacific )
print pst.strftime( "%a %b %d %X" )
我们得到:
Mon Jan 18 17:30:16 Mon Jan 18 17:30:16
我发现如果我添加%z,我可以添加它应该计算的差异:
Mon Jan 18 17:32:38 Mon Jan 18 17:32:38 -0800
它只是在那里加-8,好像在说,"你自己做,foo."
但是我希望strftime()能够简单地给我一个具有预定时间的字符串.
当我strftime()时,如何让strftime()为我做小时减法数学呢?
我正在使用的完整代码如下.
from datetime import tzinfo, timedelta, datetime
ZERO = timedelta(0)
HOUR = timedelta(hours=1)
# A UTC class.
class UTC(tzinfo):
"""UTC"""
def utcoffset(self, dt): …Run Code Online (Sandbox Code Playgroud) 这是一个简单的问题,但我看不到它:
char *s = "f 8.649292" ; double d ; sscanf( s, "f %f", &d ) ; printf( "d is %f\n", d ) ;
为什么d不包含双值8.649292?