Adding Subsidy to the View Hierarchy
I want the view to be displayed when the user clicks a button. The hierarchy looks like this:
MainWindow
-UIView
--ScrollView
---ScrollView.pages = UIViews
----UIView (from above assignment)
----TextView
----InfoButton
pages are NSMutableArry objects for pageController objects. These hooks to thread. These pens are the pages that the user scrolls through.
Clicking the InfoButton connects like this:
- (IBAction) infoButton_click:(id)sender{
topView topViewViewController *topView = [[topViewViewController alloc] initWithNibName:@"TopView" bundle:[NSBundle mainBundle]];
//[self.navigationController pushViewController: topViewView animated:YES];
//[self.view addSubview: topViewView.view];
[super.view addSubview: topViewView.view];
[topViewView release];
}
The InfoButton is on one of the pages in the ScrollView. I have commented out other code that has been tried. None of this adds performance. Nothing happened. Is there a way to get the TopView as the top view in the hierarchy?
a source to share
Is your goal to add the view as a subquery, or slide over a new view using a navigation controller? I'm going to take the latter for now.
- (IBAction)infoButton_click:(id)sender
{
TopViewController *topViewController = [[TopViewController alloc] initWithNibName:@"TopView" bundle:nil];
[self.navigationController pushViewController:topViewController animated:YES];
[topViewController release];
}
This is correct if you actually have a navigationController. Make sure you really are. When "nothing is happening" in Cocoa, it usually means something is zero. You should check with the debugger or with NSLog()
to see if any of these values ββare present. It's possible (even likely) that your parent has a navigationController, but you don't.
Classes should always have major capital. Don't create a variable named "view" that has a class "UIViewController". This is a sure path to suffering. Objective-C is a dynamic language with limited type compiler checks. Naming things correctly is critical to effective programming in ObjC.
a source to share
Based on your comment on the previous answer, you want to present a modal view. You do this by creating a new view " modalView
" and a caller [topView presentModalViewController:modalView animated:YES]
.
In a future version of the iPhone OS, which would of course not be able to comment if it was under the NDA, you could introduce a flip navigation modal view controller by setting a property on the view controller which will probably be named modalTransitionStyle
or somesuch.
a source to share