小编Jon*_*han的帖子

有没有办法避免在每个segue之后调用viewDidLoad?

我在我的主ViewController中初始化表,数据等.对于更多设置,我想调用另一个Viewcontroller:

 DateChangeController *theController = [self.storyboard instantiateViewControllerWithIdentifier:@"dateChangeController"];
[self presentViewController:theController animated:YES completion:^{NSLog(@"View controller presented.");}];
Run Code Online (Sandbox Code Playgroud)

然后一些点击我返回一个segue(自定义:)

NSLog(@"Scroll to Ticket");
[self.sourceViewController presentModalViewController:self.destinationViewController animated:YES];
Run Code Online (Sandbox Code Playgroud)

我的问题:

在返回到我的主ViewController之后,调用了viewDidLoad(每次).我读到,ARC在"转到"另一个ViewController并调用viewDidUnload方法后释放我的mainView,但是我想保留我的所有数据和表格一开始..

有解决方案吗 非常感谢你!

iphone storyboard viewdidload segue

2
推荐指数
1
解决办法
2010
查看次数

以编程方式在ScrollView中复制现有的UIView?(故事板)

我使用Storyboard,我想复制并添加一个现有的UIView(所有"孩子",如UILabels)以编程方式添加到ScrollView.所以首先我为该视图创建了一个自定义的UIView-Class (EventView),其中我通过标识它们来初始化UILabels的新文本.现在我想将这些EventView添加到Scrollview中,如下所示:

CGRect rect = CGRectMake(0.0, 0.0, 320, 320*10);
UIView *theView = [[UIView alloc] initWithFrame:rect];

for (int i = 0; i<10; i++)
{
     CGRect rC = CGRectMake(0.0, 320*i, 320, 320);

    EventView *dV = [[EventView alloc] initWithFrame:rC];
   [dV inWithEvent:allEvents[i]];//Strings for the UILabels
    [theView addSubview:dV];

}

theScrollView.contentSize = rect.size;
[theScrollView addSubview:theView];
}
Run Code Online (Sandbox Code Playgroud)

有更好的(和工作)解决方案吗?谢谢!

xcode objective-c storyboard uiscrollview uiview

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