

IPhone application - adding another view
source link: https://www.codesd.com/item/iphone-application-adding-another-view.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

IPhone application - adding another view
I am working on an iPhone app but found that I require another view / window to get the user to input and save data / information there.
How do I add another view? Do I add it in interface builder and then link it in the main app delegate or will it have its own .h and .m files.
I selected a window view app to start with, do I need to start over with a flip side view app or can this just be added in anyway if I have the correct code there.
manny thanks
The Window app is perfect for you. In your AppDelegate file, you should have a section like this:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
//instantiate the venue view controller object
YourViewController *yourViewController = [[YourViewController alloc] initWithNibName:@"YourView" bundle:[NSBundle mainBundle]];
// Configure and show the window
[window addSubview:[yourViewController view]];
[window makeKeyAndVisible];
}
This is the part of the code that declares, allocates and adds your custom view to the window. You have a couple choices for how to add the second view. You can either add it in place of this one, or add it after this one using a Navigation Controller. To add the navigation controller, change the above method to look like this:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
//instantiate the venue view controller object
YourViewController *yourViewController = [[YourViewController alloc] initWithNibName:@"YourView" bundle:[NSBundle mainBundle]];
UINavigationController *yourViewControllerWrapper = [[UINavigationController alloc] initWithRootViewController: yourViewController];
// Configure and show the window
[window addSubview:[yourViewControllerWrapper view]];
[window makeKeyAndVisible];
}
There, we create your custom view, then wrap it in a navigation controller. The navigation controller is what gets added to the window. Next the code to switch to the second view would look like this, assuming you switch views on a button press:
-(IBAction)switchViewController{
MySecondViewController *secondViewController = [[MySecondViewController alloc] init];
[self.navigationController pushViewController:secondViewController];
}
Of course, you should replace the line
MySecondViewController *secondViewController = [[MySecondViewController alloc] init];
with the proper way of instantiating your second view controller. This could be from a nib file like above, or programmatically.
As far as creating the view files, you should create a nib in Interface builder for the layout of everything, then create a .h
and .m
file for the ViewController
code itself.
Recommend
-
9
Adding Another Output Argument to a Function I need to add another output argument to a function I made last week,...
-
6
PostMac 001 -- Adding pbcopy to ElementaryOS or Another Unix Nov 5, 2016 Well as will become clear in another few blog posts, I took ElementaryOS and installed it on my 2012 MBP with 16 gigs RAM and 768 mb SSD...
-
7
Adding a View Source Menu item to Macromedia Flash Content Thursday, April 7, 2005 Yesterday [Lawrence Lessig][1] gave a talk at the FlashForward conference titled [The Cost of Copyright][2]. In it, he stressed the...
-
5
Computer monitors Boost Productivity by Adding Another Monitor to Your MacBook, Microsoft Surface, and More ...
-
5
Alright lads, this will be a quick one. I want to add the views count functionality on my personal portfolio website's blog section. Expected behavior: Blogs Page : List of blogs -> Show count. Blog Page :...
-
8
How do I view the contents of a file with another file? advertisements I have the file1 with the following cont...
-
4
Adding Another Column to a Table in my Web App » Stuart’s MATLAB Videos Here I am going to try and add an additional column to a table in my web app. Its been more than a year since I worked on this app, so I need to first f...
-
9
How to call a jquery function of a view in another view encoder advertisements I have a header view which is loaded in ever...
-
4
Give it the Old College Try: Another View of the College Enrollment Conundrum
-
4
Google is adding another layer of testing for Chrome updates / In February 2023, Chrome will include an ‘early stable’ preview in its update release cycle.By
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK