【发布时间】:2017-03-30 20:09:46
【问题描述】:
我有一个故事板,其中放置了我的所有视图控制器。我使用StoryboardID 作为:
AddNewPatientViewController * viewController =[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"addNewPatientVC"];
[self presentViewController:viewController animated:YES completion:nil];
在AddNewPatientViewController 中,我添加了一个自定义初始化方法或构造函数,您可以这样说:
-(id) initWithoutAppointment
{
self = [super init];
if (self) {
self.roomBedNumberField.hidden = true;
}
return self;
}
所以我的问题是通过使用上述呈现视图控制器的 wat,我如何使用我制作的这个自定义 init init 它。
我已尝试将其作为上述代码的替换,但没有奏效。
AddNewPatientViewController *viewController = [[AddNewPatientViewController alloc] initWithoutAppointment];
[self presentViewController:viewController animated:YES completion:nil];
【问题讨论】:
-
嗨,Talha,如果您使用的是故事板,那么使用故事板 segues 尤其是在“prepareForSegue”方法中自定义您的呈现控制器可能会是更清洁的解决方案?
标签: ios objective-c constructor uistoryboard init