hi guys i am new to iphone apps development please help me to sho开发者_运维知识库w another view from one view using buttons
Thats a very vague question... here is a start - you can look up some of the syntax and research a bit:
this in viewDidLoad:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"Click" forState:UIControlStateNormal];
[button addTarget:self action:@selector(showView) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
[button release];
then this method
- (void)showView {
UIView *view = [[UIView alloc] initWithFrame:CGRect(0,0,320,460)];
[self.view addSubview:view];
[view release];
}
if you want to push a view controller then you need to look up navigation controllers and the method pushViewController:animated:
This is the common code u can use to go on next view or go on back, Just change button name which u want to press and the view name on which u want to go. For example on back button press u want to go on library view then write this code -
-(IBAction)backButtonPressed:(id) sender
{
libraryView *libraryview=[[libraryView alloc] initWithNibName:nil bundle:nil];
libraryview.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[self presentModalViewController:libraryview animated:YES];
[libraryview release];
}
Let me know whether ur problem is solved or not.
精彩评论