2014-04-03 25 views
0

我有1個原始標籤,標籤A,其中包含一個按鈕原因請看到第二的ViewController(B)。在VC B中,選擇了一個數字並更改標籤A中的標籤以表示該數字(所有這些都完美無缺)。如何使用標籤欄控制器傳輸視圖控制器之間的浮點值?

我有,使一個新的選項卡的方法,我需要知道如何從標籤A和VC B中的浮點值被確認爲標籤C(新標籤)相同的值。任何幫助表示讚賞!

編輯:這是我必須做出一個新的標籤

-(void)makeNewTab: (NSString *)linkToSnipe { 

NSMutableArray* tabs = [[NSMutableArray alloc] init]; 
[tabs addObjectsFromArray:self.tabBarController.viewControllers]; 
NewLinkViewController* newVC = [self.storyboard instantiateViewControllerWithIdentifier:@"Link"]; 
[tabs addObject: newVC]; 
UITabBarItem* item = [[UITabBarItem alloc] init]; 
NSString* itemTitle = [NSString stringWithFormat:@"Link # %lu", (unsigned long)[itemsAlreadyAddedToCart count]]; 
[item setTitle: itemTitle]; 
[item setImage:[UIImage imageNamed:@"shoe.png"]]; 
[newVC setTabBarItem:item]; 
[self.tabBarController setViewControllers: [NSArray arrayWithArray:tabs]]; 
int indexOfNewTab = [tabs count]-1; 
[newVC setLinkToSnipe:linkToSnipe]; 
[newVC setSizeIWant: sizeChosen]; 
self.tabBarController.selectedIndex = indexOfNewTab; 

}方法

setLinkToSnipe:linktosnipe完美的作品,該字符串被稱爲新標籤同樣的事情。 setSizeIWant:sizeChosen不起作用。選擇大小是浮點值,我需要在標籤Ç

+0

這些「選項卡」控制器在標籤視圖控制器?你在說什麼按鈕,從選項卡A到選項卡B?其中一個標籤欄按鈕(沒有賽格瑞嵌入到標籤欄控制器控制器之間去的時候,所以我不明白你在說什麼)? – rdelmar

回答

0

沒有看到你的代碼,這是一個有點難以作出其他建議,而不是做你現在正在做它的標籤A和B.當您創建標籤之間以同樣的方式C,給它一個屬性,無論創建它,它都會被設置。

0

你必須有在標籤下的浮點值:

@property (nonatomic) float floatValue; 

,並通過加入以下在標籤B和標籤A的端部進行更改:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{ 
    if([segue.identifier isEqualToString:@"segue"]){ 
     ViewCont *vc = segue.destinationViewController; 
     vc.floatValue = value; 
    } 

} 
相關問題