Ios 使用tabBar在视图之间传递数据
好的,我有我的应用程序的一部分,我正在努力在视图之间传递浮点变量,一切都很好,但是所有的按钮看起来有点乱。我想看看是否可以在现有视图中添加一个tabBar并清理它。我找到了一个很好的教程,让它链接起来并报告我在NSLog中选择的选项卡,所以继续粘贴我用于相同功能的按钮的代码。一切都有点搞笑,我不得不做一些新的变量,我只剩下最后一个我无法理解的错误。 这是我第一次调用patternRafter时调用的预期表达式Ios 使用tabBar在视图之间传递数据,ios,xcode,uiviewcontroller,expression,uitabbar,Ios,Xcode,Uiviewcontroller,Expression,Uitabbar,好的,我有我的应用程序的一部分,我正在努力在视图之间传递浮点变量,一切都很好,但是所有的按钮看起来有点乱。我想看看是否可以在现有视图中添加一个tabBar并清理它。我找到了一个很好的教程,让它链接起来并报告我在NSLog中选择的选项卡,所以继续粘贴我用于相同功能的按钮的代码。一切都有点搞笑,我不得不做一些新的变量,我只剩下最后一个我无法理解的错误。 这是我第一次调用patternRafter时调用的预期表达式 - (void)tabBar:(UITabBar *)tabBar didSelect
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
NSLog(@"didSelectItem: %d", item.tag);
[self activateTab:item.tag];
}
- (void)activateTab:(int)index {
switch (index) {
case 1:
patternRafter *patternRafter1 = [[patternRafter alloc]initWithNibName:nil bundle:nil];
BuildNavAppDelegate *buildNavDelegate = (BuildNavAppDelegate *)[[UIApplication sharedApplication]delegate];
buildNavDelegate.TLPMR = [TLMR text];
buildNavDelegate.comRaftBirdPassed = [comBird text];
buildNavDelegate.comRaftLengthPassed = [comRafter text];
buildNavDelegate.raftThicknessPassed = [rafterWidth text];
[self presentModalViewController:patternRafter1 animated:YES];
break;
/*case 2:
buildersSquare *square1 = [[buildersSquare alloc]initWithNibName:nil bundle:nil];
BuildNavAppDelegate *buildNavDelegate = (BuildNavAppDelegate *)[[UIApplication sharedApplication]delegate];
buildNavDelegate.TLPMR = [TLMR text];
buildNavDelegate.comRaftBirdPassed = [comBird text];
buildNavDelegate.comRaftLengthPassed = [comRafter text];
buildNavDelegate.raftThicknessPassed = [rafterWidth text];
[self presentModalViewController:square1 animated:YES];
break;
case 3:
self.tab2ViewController =[[tab2 alloc] initWithNibName:@"tab2" bundle:nil];
[self.view insertSubview:tab2ViewController.view belowSubview:tabbar1];
if (currentViewController != nil)
[currentViewController.view removeFromSuperview];
currentViewController = tab2ViewController;
break;*/
default:
break;
}
}
任何帮助都将不胜感激。谢谢
我刚刚意识到我不能发布图片,因为我还是一个新用户。如果有人想查看,这里有一个链接。
我想patternRafter是一个名为patternRafter的类的实例?如果是这样,该行需要如下所示:
PatternRafter *patternRafter1 = [[PatternRafter alloc] initWithNibName:nil bundle:nil];
Obj-C区分大小写,命名约定要求IVAR以小写开头,类以大写开头
- (void)activateTab:(int)index {
switch (index) {
case 1://igot it to work by opening brackets here{
patternRafter *patternRafter1 = [[patternRafter alloc]initWithNibName:nil bundle:nil];
BuildNavAppDelegate *buildNavDelegate = (BuildNavAppDelegate *)[[UIApplication sharedApplication]delegate];
buildNavDelegate.TLPMR = [TLMR text];
buildNavDelegate.comRaftBirdPassed = [comBird text];
buildNavDelegate.comRaftLengthPassed = [comRafter text];
buildNavDelegate.raftThicknessPassed = [rafterWidth text];
[self presentModalViewController:patternRafter1 animated:YES]; //local declaration of 'patternRafter1' hides instance variable
break;//and closing here}
case 2:
它工作正常,但我收到了警告--“patternRafter1”的本地声明隐藏了实例变量对不起,我最近在其他帖子上看到了这一点,现在我知道了,谢谢。不用担心。那个答案对你有用吗?不,那个答案不起作用。但我现在明白他的意思了。这是我第一次尝试一个应用程序,开始的时候非常草率,所以就这一次而言,我继续使用坏习惯,只是为了让它继续工作。不过,我确实在其他地方找到了一些帮助,解决了这个问题,但仍然给我留下了一些警告。我不能回答我自己的问题,因为我仍然是一个新用户2小时。