【发布时间】:2013-03-02 23:10:41
【问题描述】:
我是 iOS 开发的新手,我已经阅读了大量关于这个问题的文章,但仍然无法弄清楚。
我在操作表中有一个按钮,它应该激活并呈现一个上滑模式,它是一个从/到日期选择屏幕(它有自己的控制器 DatePickerViewController。操作表由一个按钮触发在 NavigationViewController 的子视图的工具栏中(“Map of Shows”视图,左上角按钮)。图形显示了当前的故事板关系:
此序列的代码如下所示:
// ShowsContainerController.m
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if( buttonIndex == 1 ){
// 1. Activates from actionsheet
[(NavigationViewController *)self.parentViewController showDateSelect];
}
}
// NavigationViewController.m
// 2. fires up the datepicker view
-(void)showDateSelect
{
pickerView = [[DatePickerViewController alloc] init ];
[self presentViewController:pickerView animated:YES completion:nil];
}
// DatePickerViewController.m
// 3. Instantiation of this controller. Definitely fires nslog.
-(void)viewDidLoad
{
NSLog(@"Here");
}
一旦“这里”,屏幕就会变黑。我认为这是因为我没有在日期选择器控制器的实例化或对它的 segue 上做正确的事情。所有有问题的视图都与故事板配置中它们各自的控制器相关联。为了进一步混淆这个问题,我有一个为另一个屏幕创建的 UITableViewController,只是为了大便和咯咯笑,尝试加载它,它工作正常。然后我创建了另一个完全独立的 UIViewController,将它指向控制当前非工作的控制器文件,它也爆炸了,所以我认为问题是非工作 UIViewController 的头文件和主文件。 编辑。划掉最后一个音符;我为视图创建了一个全新的标头、主文件和 NIB,但它仍然无法正常工作。我不知道这到底是什么交易。
我们将不胜感激。
附录
- (IBAction)showOptions:(id)sender
{
NSString *showTypes;
if( self.onlyShowPreferredEvents ){
showTypes = @"\u2713 Only shows that I'll like";
} else {
showTypes = @"Only shows that I'll like";
}
_showDisplayOptionsActionSheet = [[UIActionSheet alloc] initWithTitle:@"Event Display Settings" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles: showTypes, @"Date Range", nil];
[_showDisplayOptionsActionSheet showFromTabBar:self.tabBarController.tabBar];
}
根据 cmets。
附录 2 // DatePickerViewController.m的全部
#import "DateRangeViewController.h"
@interface DateRangeViewController ()
@end
@implementation DateRangeViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
// All of DatePickerViewController.h
#import <UIKit/UIKit.h>
@interface DateRangeViewController : UIViewController
@end
【问题讨论】:
-
操作表上的按钮不应该直接连接到 datePickerViewController 的任何原因?为什么需要 datePickerViewController 连接到 Nav 控制器?
-
操作表是动态创建的,所以我不确定如何实现。我将更新我的操作表实例化代码。
-
请在下面查看我更新的答案。
标签: ios ios6 uiviewcontroller uistoryboardsegue