Я только начал Objective-C и ищу способ создать приложение для iPhone, которое будет запускаться с главным меню, состоящим, возможно, из 8 или 9 кнопок.
Когда кнопки нажимаются, он будет ссылаться на представление «Прокручиваемый текст» (содержащее несколько абзацев текста) с сопровождающим изображением в верхней части экрана, которое будет действовать как кнопка «Назад», чтобы вернуться на главную Меню. Я также искал его, чтобы анимировать / вести себя как модальное представление (когда новое представление прокручивается вверх от нижней части экрана и прокручивается вниз при отклонении / нажатии кнопки Back).
У меня есть представления вкладок, работающие в модальном представлении (которое вызывается нажатием кнопки в главном меню), и я разработал, как назначить пользовательский значок для каждой вкладки. Я также добавил собственный фон для каждой вкладки. Хотя у меня все еще возникают проблемы с добавлением прокручиваемых видов на каждую вкладку, где я могу вставлять картинки и текст программно. Я был бы очень признателен за любую помощь, которую вы могли бы оказать мне с этим ..
Большое спасибо !!
.h
#import <UIKit/UIKit.h>
@interface MasseurViewController : UIViewController {
UITabBarController *tbc;
}
-(IBAction)showHeadTabBar;
-(void)dismissTabBar;
@property (nonatomic, retain) UITabBarController *tbc;
@end
.m
#import "MasseurViewController.h"
@implementation MasseurViewController
@synthesize tbc;
//---Implement all the possible Tab Bar views
-(IBAction)showHeadTabBar{
//---Define Back button
UIImage *backImage = [UIImage imageNamed:@"headBackButton.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0.0f, 0.0f, backImage.size.width, backImage.size.height);
[button setImage:backImage forState:UIControlStateNormal];
[button addTarget:self action:@selector(dismissTabBar) forControlEvents:UIControlEventTouchUpInside];
UIButton *button2 = [UIButton buttonWithType:UIButtonTypeCustom];
button2.frame = CGRectMake(0.0f, 0.0f, backImage.size.width, backImage.size.height);
[button2 setImage:backImage forState:UIControlStateNormal];
[button2 addTarget:self action:@selector(dismissTabBar) forControlEvents:UIControlEventTouchUpInside];
UIButton *button3 = [UIButton buttonWithType:UIButtonTypeCustom];
button3.frame = CGRectMake(0.0f, 0.0f, backImage.size.width, backImage.size.height);
[button3 setImage:backImage forState:UIControlStateNormal];
[button3 addTarget:self action:@selector(dismissTabBar) forControlEvents:UIControlEventTouchUpInside];
//------------************TABS**************-------------------
//-------------------------------------------------------------
//---------------Declare View Controllers-----------
//---------------------------TAB 1
UIViewController *blueController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
blueController.title = @"Blue";
blueController.tabBarItem.image = [UIImage imageNamed:@"tabBar1.png"];
//---Add tabs & Tab names
[blueController.view addSubview:button];
blueController.view.backgroundColor = [UIColor whiteColor];
blueController.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"mainMenuBKG.png"]];
//----TAB 2
UIViewController *redController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
redController.view.backgroundColor = [UIColor grayColor];
redController.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"shouldersImage1.png"]];
//----TAB 3
UIViewController *greenController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
greenController.view.backgroundColor = [UIColor greenColor];
//--------------------------------------------------
//---Instantiate tab bars
tbc = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
//---Create array of tabs
tbc.viewControllers = [NSArray arrayWithObjects:blueController, redController, greenController, nil];
//---Select starting tab
tbc.selectedViewController = blueController;
//--------------------------------------------------
//---Add tabs & Tab names
[redController.view addSubview:button2];
redController.title = @"Red";
[greenController.view addSubview:button3];
greenController.title = @"Green";
//---Release Tab views
[blueController release];
[redController release];
[greenController release];
[self presentModalViewController:tbc animated:YES];
}
//---Code to dismiss Tab Bars
- (void)dismissTabBar {
[self dismissModalViewControllerAnimated:YES];
[tbc release];
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end