titleView在segue之后跳转

时间:2016-09-09 23:41:33

标签: ios objective-c uinavigationcontroller uisplitviewcontroller

在我的应用中,我有一个UINavigationController,其中UISplitViewController为rootViewController。此UISplitViewController的masterViewController将UIView设置为UITextField,其中titleView- (void)viewDidLoad { [super viewDidLoad]; self.titleView = [[UIView alloc] initWithFrame:CGRectMake((self.view.frame.size.width-((self.view.frame.size.width/2)+150))/2, 0, (self.view.frame.size.width/2)+150, 30)]; self.rightButton = [[UIButton alloc] init]; [self.rightButton setImage:newImage forState:UIControlStateNormal]; [self.rightButton addTarget:self action:@selector(barButtonRight:) forControlEvents:UIControlEventTouchUpInside]; self.rightButton.frame = CGRectMake(0, 0, 30, 30); self.rightButton.tintColor = [UIColor whiteColor]; [self.rightButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:self.rightButton]; self.splitViewController.navigationItem.rightBarButtonItem = rightButton; self.textField = [[UITextField alloc]init]; if (IDIOM == IPAD) { self.textField.frame = CGRectMake(0, 0, self.titleView.frame.size.width, 30); } else { self.textField.frame = CGRectMake(65, 0, (self.view.frame.size.width-20)-110, 30); } self.textField.backgroundColor = [UIColor purpleColor]; if (IDIOM == IPAD) { UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 15, 20)]; self.textField.leftView = paddingView; self.textField.leftViewMode = UITextFieldViewModeAlways; } [self.titleView addSubview:self.textField]; self.splitViewController.navigationItem.titleView = self.titleView; [self.navigationController setNavigationBarHidden:YES animated:NO]; } 。这是在故事板中看起来像。enter image description here

- (IBAction)barButtonRight:(id)sender {
    [self performSegueWithIdentifier:@"showDetail" sender:self];
}

现在,当按下右键时会发生奇怪的事情。

UITextField

UIView一直推到viewDidLoad内的左侧。我评论了大部分# inittab is only used by upstart for the default runlevel. # # ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM 代码,但这仍然存在。关于导致这种情况的任何想法?

0 个答案:

没有答案