小编Jak*_*čar的帖子

scrollsToTop不工作

我有以下对象结构:

  • 的UITabBarController
    • UINavigationController的
      • 的UITableViewController

它曾经工作,但后来我将UITabBarController添加到混合中,并进行了一系列其他大的更改,并在它之间停止了.

到目前为止,我有:

  • 创建了一个具有该结构的新项目,这似乎工作正常.
  • 检查了只有一个带有scrollsToTop的视图
  • 尝试直接在UITabBarController下添加一个新的UITableViewController ...仍然无法正常工作.

可能有用的一件事-scrollViewShouldScrollToTop:是即使表视图控制器tableView.delegate设置为控制器,也不会被调用.

iphone cocoa-touch objective-c

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

使用接近传感器而不关闭屏幕

这是一个很长的镜头,但是有没有人知道在使用接近传感器(UIDevice.proximityMonitoringEnabled和proximityState)时避免自动屏幕消隐的方法?

iphone

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

UIInterfaceOrientationLandscapeLeft和UIInterfaceOrientationLandscapeRight是否相反?

文件说:

UIInterfaceOrientationLandscapeLeft

设备处于横向模式,设备直立,主页按钮位于右侧.

UIInterfaceOrientationLandscapeRight

设备处于横向模式,设备直立,主页按钮位于左侧.

但是,我让他们完全颠倒了.SDK中真的会出现这样的错误,还是我只是疯了?

码:

+ (NSString *)NSStringFromUIInterfaceOrientation:(UIInterfaceOrientation)o
{
    switch (o) {
        case UIInterfaceOrientationPortrait: return @"UIInterfaceOrientationPortrait";
        case UIInterfaceOrientationPortraitUpsideDown: return @"UIInterfaceOrientationPortraitUpsideDown";
        case UIInterfaceOrientationLandscapeLeft: return @"UIInterfaceOrientationLandscapeLeft";
        case UIInterfaceOrientationLandscapeRight: return @"UIInterfaceOrientationLandscapeRight";
    }
    return nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    NSLog(@"Should: %@", [[self class] NSStringFromUIInterfaceOrientation:toInterfaceOrientation]);
    return YES;
}    
Run Code Online (Sandbox Code Playgroud)

我将上面的代码粘贴到默认的基于导航的应用程序模板的RootViewController.m中.

后续行动:报告为错误7216046.

iphone cocoa-touch uikit

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

ABPeoplePickerNavigationController替代方案,允许选择多个人

我想提示用户从他们的地址簿中选择一个或多个人,但ABPeoplePickerNavigationController不允许这样做(具有讽刺意味的是,因为它是人物选择器,而不是人员选择器).

在我创建自己的之前,有没有人知道这种控制器的替代(开源)实现?

iphone uikit

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

stdin/stderr是否保证在进程终止后关闭?

我使用pipe(),fork(),dup(),execve()生成子进程.

从父级,是否可以安全地等待子级的stdin和stdout关闭(即read()返回0),然后执行waitpid()来收集终止状态?

或者,如果没有关闭stdin和stdout,进程会失败吗?(因此我的程序永远不会得到waitpid)


为了澄清,我问以下是否安全:

while (child_stdin != -1 && child_stdout != -1) {
    poll(...)

    if (got_stdout) {
        n = read(child_stdout);
        if (n >= 0) {
            // do something with output
        } else if (n == 0) {
            child_stdout = -1
        }
    }

    // same for stdin
}

waitpid(child_pid)
Run Code Online (Sandbox Code Playgroud)

或者可能会发生孩子终止,但我永远不会在read()或write()上得到0.

没有信号,只有poll() - ing.

c posix

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

'Nil'在Obj-C中代表什么?

因此NULL,它通常用于指针,并且nil用于对象指针.

现在我也看到了Nil,它也被更低级的Obj-C运行时函数所使用class_getProperty.

这在某种程度上与nil哲学不同吗?(是的,我知道他们实际上都是0)

它为什么甚至被引入?或者,如果Nil是第一个(很可能),为什么会被nil引入?

objective-c

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

标签 统计

iphone ×4

cocoa-touch ×2

objective-c ×2

uikit ×2

c ×1

posix ×1