presenting a view not working in iphone

我是研究僧i 提交于 2019-12-25 08:20:52

问题


I am trying to navigate from one page to another on a button click in a facebook appliaction.
I am using

registerUser=[[RegisterPage alloc]initWithNibName:@"RegisterPage" bundle:nil];
[self presentModalViewController :registerUser animated:YES];

for presenting the next view after getting response from facebook.
But it is not showing the next view. It works fine in all other places where I used to present other views.

Anyone have idea about this issue?


回答1:


What exactly is 'self' here? Is it a viewcontroller? Or just a UIView? I think this'll only work if self is a viewcontroller or some subclass of it.




回答2:


My code to present a view controller is somewhat like yours (without a nib):

ViewController *controller = [[ViewController alloc] initWithNibName:nil bundle:nil];
[controller setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentModalViewController:controller animated:YES];
[controller release];

And to present a navigation controller it's like this (without a nib):

ViewController *controller = [[ViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navController = [[UINavigationController alloc]       initWithRootViewController:controller];
[navController setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentModalViewController:navController animated:YES];
[navController release];
[controller release];

Sometimes simply copying someones code helps.




回答3:


thanks for everyones reply.i have solved it after a long fight.i just dismissed the view before pesenting the next view and set dismissmodalviewcontrollerAnimated to NO.[self dismissModalViewControllerAnimated:NO]; nextview = [[LoginPage alloc]initWithNibName:@"LoginPage" bundle:nil]; [self presentModalViewController: nextview animated:YES];hope this help someone like me



来源:https://stackoverflow.com/questions/8832610/presenting-a-view-not-working-in-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!