开发者

what am I doing wrong in attempt to popup a web view and then allow user to go back

开发者 https://www.devze.com 2023-02-13 07:45 出处:网络
my app has tabBarController with 3 views and in one of them I want to popup a web browser with the ability to return back to the application. To do that I am using UINavigationController.

my app has tabBarController with 3 views and in one of them I want to popup a web browser with the ability to return back to the application. To do that I am using UINavigationController.

In myAppDelegate.h I have defined the property UINavigationController *nav and in myAppDelegate.m I have @synthesize nav.

In the class where the webPopup function resides upon pressing the button my code comes to this function.

- (IBAction)showWeb:(id)sender {
myAppDelegate *app=[[UINavigationController allo开发者_开发知识库c] initWIthRootViewController:self];
// because I want to return back to the same view
webController *web = [[webController alloc] initWithStyle:UITableViewStypeGrouped];
[app.nav pushViewController:web animated:YES];
app.nav.view.frame = CGRect(,0,320,430);
[self.view.window addSUbview:app.nav.view];
}

The web popup occurs but it is moved vertically, when I press "back button" my former view appears as well and it is also shifted vertically from what it was before. After going back and forth few times the thing hangs.

Questions:

1. what can cause the shift?

2. how to avoid when I go "back" to see the title(test from the "back"button, I think this might cause a shift when I go back.

3. how to find out why it hangs after few attempt?

Thanks. Victor


The line:

myAppDelegate *app=[[UINavigationController alloc] initWIthRootViewController:self];

makes no sense to me. Surely your compiler is warning you about that? What is "myAppDelegate" defined as? Classes should have a capital letter at the front, by the way.

Also, the line

[self.view.window addSUbview:app.nav.view];

is highly suspect, because the UIWindow for your application should have only one child UIView. You shouldn't just add more views willy nilly and expect things to work. It is possible to change the child UIView by removing the old one and adding a new one, but you don't seem to be doing that. Having more than one child UIView of UIWindow gets you into trouble very quickly -- for example, device orientation changing can break.


I'm not exactly clear as to why the app delegate (or the window for that matter) needs to be messed with at all to do what you are trying to do. Sounds like you should just be using standard Nav View Controllers and Web Views.

Also, you are alloc init'ing w/o any memory management.

0

精彩评论

暂无评论...
验证码 换一张
取 消