在我的应用程序中我有3个UIViews(3 .xib)和3个按钮,每个视图一个按钮,但我不知道如何编程视图的问题总是我有错误和警告我试图让视图出现像实用程序应用程序中的信息按钮,但我必须回到原始视图,我遇到了委托问题
那么有什么方法可以通过按下它的按钮来显示视图,就像TabBareController一样,因为我想按钮始终存在于每个视图中而我不这样做想要使用使用标签栏的应用程序。
由于
编辑:
第一个ViewControler.m中的
- (void)viewDidLoad {
//Load the image
UIImage *buttonImage = [UIImage imageNamed:@"bt_tweet_S.png"];
//create the button and assign the image
UIButton *tweet = [UIButton buttonWithType:UIButtonTypeCustom];
[tweet setImage:buttonImage forState:UIControlStateNormal];
//sets the frame of the button to the size of the image
tweet.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);
//creates a UIBarButtonItem with the button as a custom view
UIBarButtonItem *tweetbar = [[UIBarButtonItem alloc] initWithCustomView:tweet];
tweetbar.tag = 1;
//Load the image
UIImage *pageImage = [UIImage imageNamed:@"bt_web.png"];
//create the button and assign the image
UIButton *page = [UIButton buttonWithType:UIButtonTypeCustom];
[page setImage:pageImage forState:UIControlStateNormal];
[page addTarget:self action:@selector(flipAction:) forControlEvents:UIControlEventTouchUpInside];
//sets the frame of the button to the size of the image
page.frame = CGRectMake(0, 0, pageImage.size.width, pageImage.size.height);
//creates a UIBarButtonItem with the button as a custom view
UIBarButtonItem *pagebar = [[UIBarButtonItem alloc] initWithCustomView:page];
pagebar.tag = 2;
//Load the image
UIImage *infoImage = [UIImage imageNamed:@"bt_info.png"];
//create the button and assign the image
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeCustom];
[infoButton setImage:infoImage forState:UIControlStateNormal];
[infoButton addTarget:self action:@selector(showInfo:) forControlEvents:UIControlEventTouchUpInside];
//sets the frame of the button to the size of the image
infoButton.frame = CGRectMake(0, 0, infoImage.size.width, infoImage.size.height);
//creates a UIBarButtonItem with the button as a custom view
UIBarButtonItem *infoBar = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
//infoBar.target= self;
//infoBar.action= @selector(showInfo:);
//infoBar.tag = 3;
UIBarItem* space = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:
UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease];
_toolbar = [[UIToolbar alloc] initWithFrame:
CGRectMake(0, 460 - 44, 320, 44)];
_toolbar.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
_toolbar.tintColor = [UIColor blackColor];
_toolbar.items = [NSArray arrayWithObjects:space,tweetbar, space,pagebar,space,infoBar,space, nil];
[self.view addSubview:_toolbar];
[tweetbar release];
[super viewDidLoad];
}
并在每个视图中使用相同的代码
答案 0 :(得分:0)
从我可以挤出你的帖子,你希望能够以随机顺序在3个视图之间移动。使用导航控制器和pushViewController:/ popViewController:对此不太好。
最好使用标签栏。