我想要移动一个屏幕到下一个,并为此编写代码,但它不移动下一个屏幕上的按钮click.what是这个代码中的问题。
我想要移动一个屏幕到下一个,并为此编写代码,但它不移动下一个屏幕上的按钮click.what是这个代码中的问题。
smsDisplayViewController.h
@interface smsDisplayViewController : UIViewController<UITextFieldDelegate>
{
UIButton *btncomment;
}
- (IBAction)btncomment:(id)sender;
@property(strong,nonatomic)UIButton *btncomment;
@end
smsDisplayViewController.m
@implementation smsDisplayViewController
@synthesize smsdisplay,Id,btncomment;
- (IBAction)btncomment:(id)sender
{
CommentScreenViewController *viewController = [[CommentScreenViewController alloc]
initWithNibName:@"CommentScreenViewController" bundle:nil];
[self.navigationController pushViewController:viewController animated:YES];
NSLog(@"btn press");
}
[btncomment addTarget:self action:@selector(btncomment:)
forControlEvents:UIControlEventTouchUpInside];我想移动一个屏幕到下一个,并为此代码,但它不移动在下一个屏幕上的按钮点击。我想移动一个屏幕到下一个,并为此代码,但它不移动在下一个屏幕上的按钮点击。
发布于 2014-10-30 18:32:34
如果你不想使用NavigationController,那么使用下面的代码
- (IBAction)btncomment:(id)sender
{
CommentScreenViewController *nextViewController = [[CommentScreenViewController alloc] initWithNibName:@"CommentScreenViewController" bundle:nil];
[self presentViewController:nextViewController animated: YES completion: nil];
}发布于 2014-10-30 18:12:47
我认为你自己不是一个navigationController,所以这个属性
self.navigationController返回nil!
如果需要,可以使用故事板在没有导航控制器的控制器之间切换,或者以模态方式显示新控制器:
UIViewController *newViewController = [[UIViewController alloc] init];
[self presentViewController: newViewController animated: YES completion: nil];https://stackoverflow.com/questions/26649974
复制相似问题