小编use*_*212的帖子

当呈现UINavigationController模态时,segue.destinationViewController为nil

我有一个UICollectionView当用户按下单元格时,我UINavigationController使用故事板以模态方式呈现另一个视图控制器.

- (void)collectionView:(UICollectionView *)collectionView
didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"editBookIPad"
                                      sender:indexPath];
}


- (void)prepareForSegue:(UIStoryboardSegue *)segue
                 sender:(id)sender
{
    // Did not include code for other segues, but I check which is the current one properly
    UINavigationController *dest = segue.destinationViewController; // This is nil!
    dest.modalPresentationStyle = UIModalPresentationFormSheet;
    DetailsViewController *detailsVC = (id)[dest topViewController];
    detailsVC.stack = self.stack;
    detailsVC.editingMode = 1;
    detailsVC.bookToEdit = [self.fetchedResultsController objectAtIndexPath:sender];
    [self.collectionView deselectItemAtIndexPath:sender
                                        animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

故事板

现在,我的问题是segue.desinationViewController返回nil(如代码片段中的注释所示).

只是为了调试,我改为UINavigationController另一个视图控制器,我没有问题.我不知道是否从modal更改为push作为过渡样式会有所帮助,因为它不可能推动a UINavigationController(发生崩溃事件就是这样).

我清理了项目和构建文件夹,然后重新启动了我的计算机(以及Xcode).

这是运行应用程序时的样子:

问题截图

在寻找类似的问题时,我发现了这一点.大多数其他问题是关于在目标视图控制器上设置的属性为nil(例如 …

xcode ios uistoryboardsegue

7
推荐指数
2
解决办法
3227
查看次数

基于Cocoa文档的应用程序,NSWindowController子类为"主窗口"

我有一个基于Cocoa文档的应用程序.我希望"主窗口"由我的子类管理NSWindowController.我创建了子类,并将其接口布局在一个同名的.xib文件中.我最终想要像NSDocument管理窗口一样的行为,而是让它由一个管理NSWindowController.

首先,我该怎么办?其次,在采用这种方法时,我需要考虑的是什么特别的事情,例如如何处理打开和保存?

macos nsdocument nswindowcontroller

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

在成员变量中存储 std::to_string(x).c_str() 会产生垃圾

我有一个非常简单的 C++ 程序:

using namespace std;

class TheClass
{
private:
    const char *_numberString;

public:
    TheClass(int number)
    {
        _numberString = to_string(number).c_str();
    }

    operator const char *()
    {
        return _numberString;
    }
};

int main(int argc, const char * argv[])
{
   TheClass instance = 123;
   cout << (const char *)instance << endl;

   return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我在 Xcode 中运行它时,它会记录\367\277_\377. 如果我把它改成这样:

using namespace std;

class TheClass
{
public:   // Change 1/2
    const char *_numberString;

public:
    TheClass(int number)
    {
        _numberString = to_string(number).c_str();
    }

    operator …
Run Code Online (Sandbox Code Playgroud)

c++ xcode

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