i have two view controller firstviewconroller and secondviewcontroller. i have alert view in firstviewconroller now i want to goto second secondviewcontroller. clicking alert view button. guide me how to call secondviewcontroller using code.i'm new to this stuff. here is my alert view code.
我有两个视图控制器firstviewconroller和secondviewcontroller。我在firstviewconroller中有警报视图现在我想转到第二个secondviewcontroller。单击警报视图按钮。指导我如何使用code.i'm新的东西来调用secondviewcontroller。这是我的警报视图代码。
-(IBAction)enter:(id) sender{
UIAlertView *alertBox=[[UIAlertView alloc]initWithTitle:@"ThinkTax!" message:@"0.0" delegate:self cancelButtonTitle:@"Button 1" otherButtonTitles:nil];
[alertBox addButtonWithTitle:@"Sve"];
[alertBox addButtonWithTitle:@"Button 3"];
if(FALSE)
{
[alertBox addButtonWithTitle:@"Button 4"];
}
[alertBox show];
[alertBox release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"details"])
{
UIViewController *secondViewController = [[Hello_WorldViewController alloc] initWithNibName:@"<Hello_WorldViewController >" bundle:nil];
[self Page3:secondViewController animated:YES];
[secondViewController release];
NSLog(@"Button details was selected.");
}
else if([title isEqualToString:@"mail"])
{
NSLog(@"Button mail was selected.");
}
else if([title isEqualToString:@"close"])
{
NSLog(@"Button close was selected.");
}
}
now its showing console output like this.i don't know where i'm doing wrong.
现在它显示控制台输出像this.i不知道我在哪里做错了。
-[Page3 Page3:animated:]: unrecognized selector sent to instance 0x8d26ba0
Hello World[5961:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Page3 Page3:animated:]: unrecognized selector sent to instance 0x8d26ba0'
3 个解决方案
#1
1
This is the code,
这是代码,
UIViewController *secondViewController = [[SecondViewControllerClass alloc] initWithNibName:@"<name of xib>" bundle:nil];
[self presentModalViewController:secondViewController animated:YES];
[secondViewController release];
There are several questions with the same topic, you should have search before posting this question.
同一主题有几个问题,您应该在发布此问题之前进行搜索。
#2
0
This is Very Simple You just have to create an Object of the NextViewController on which you want to go and call presentModalViewController on that.. like this.:-
这很简单你只需要创建一个你想要去的NextViewController的Object并在那个上调用presentModalViewController ..就像这样。:-
in FirstVC.h:-
@class SecondVC;
SecondViewController *viewController;
inFirstViewController.m:-
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"details"])
{
viewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self presentModalViewController:viewController animated:YES];
[viewController release];
}
else if([title isEqualToString:@"mail"])
{
NSLog(@"Button mail was selected.");
}
else if([title isEqualToString:@"close"])
{
NSLog(@"Button close was selected.");
}
}
And Yes What KingofBliss Said is very true. Please make it in Notice. Good Day.
是的,KingofBliss说的是非常真实的。请在通知中进行。美好的一天。
#3
0
i did this but app crashes on the line
我做到了这一点,但应用程序崩溃了
if([str isEqualToString:@"xxxxx"])
{
if([str1 isEqualToString:@"xxxxx"])
{
FirstListView *ab=[[FirstListView alloc]initWithNibName:@"FirstListView" bundle:nil];
[self presentModalViewController:ab animated:NO];//here app crashes
}
}
else
{
user.text=@"Wrong User";
password.text=@"";
}
which i have a login screen
我有一个登录屏幕
and on the FirstListView i have two table views. having no idea why the app crashes.
在FirstListView上我有两个表视图。不知道应用程序崩溃的原因。
#1
1
This is the code,
这是代码,
UIViewController *secondViewController = [[SecondViewControllerClass alloc] initWithNibName:@"<name of xib>" bundle:nil];
[self presentModalViewController:secondViewController animated:YES];
[secondViewController release];
There are several questions with the same topic, you should have search before posting this question.
同一主题有几个问题,您应该在发布此问题之前进行搜索。
#2
0
This is Very Simple You just have to create an Object of the NextViewController on which you want to go and call presentModalViewController on that.. like this.:-
这很简单你只需要创建一个你想要去的NextViewController的Object并在那个上调用presentModalViewController ..就像这样。:-
in FirstVC.h:-
@class SecondVC;
SecondViewController *viewController;
inFirstViewController.m:-
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"details"])
{
viewController = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self presentModalViewController:viewController animated:YES];
[viewController release];
}
else if([title isEqualToString:@"mail"])
{
NSLog(@"Button mail was selected.");
}
else if([title isEqualToString:@"close"])
{
NSLog(@"Button close was selected.");
}
}
And Yes What KingofBliss Said is very true. Please make it in Notice. Good Day.
是的,KingofBliss说的是非常真实的。请在通知中进行。美好的一天。
#3
0
i did this but app crashes on the line
我做到了这一点,但应用程序崩溃了
if([str isEqualToString:@"xxxxx"])
{
if([str1 isEqualToString:@"xxxxx"])
{
FirstListView *ab=[[FirstListView alloc]initWithNibName:@"FirstListView" bundle:nil];
[self presentModalViewController:ab animated:NO];//here app crashes
}
}
else
{
user.text=@"Wrong User";
password.text=@"";
}
which i have a login screen
我有一个登录屏幕
and on the FirstListView i have two table views. having no idea why the app crashes.
在FirstListView上我有两个表视图。不知道应用程序崩溃的原因。