1
我有這樣的代碼:比較並轉到另一個視圖控制器
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
NSDictionary *data = [list1 objectAtIndex:row];
NSNumber *strt = [data objectForKey:@"ab1"];
NSNumber *strt2 = [data objectForKey:@"ab1"];
forlb1 = [NSString stringWithFormat:@"%d", strt.intValue];
forlb2 = [NSString stringWithFormat:@"%d", strt2.intValue];
NSDictionary *xt = [list1 objectAtIndex:row];
NSString *name = [xt objectForKey:@"name"];
NSDictionary *xx = [list1 objectAtIndex:row];
NSString *name2 = [xx objectForKey:@"name"];
switch (component)
{
case 0:
show1 = name;
label1.text = forlb1;
break;
case 1:
show2 = name2;
label2.text = forlb2;
break;
}
}
- (IBAction)goView:(id)sender
{
if (label1.text < labe2.tex)
{
ViewController1 *first = [[ViewController1 alloc]init];
first.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:first animated:YES];
}
else
{
ViewController3 *third = [[ViewController3 alloc]init];
third.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:third animated:YES];
}
}
我的問題是:如果我的label1.text我不能讓ViewController3 < label2.text
當我從部件選擇1的Picker視圖中,我的一個標籤顯示名稱,另一個label1顯示一個數字,Picker視圖的組件2發生同樣的事情,現在可以,但是當我應該觸摸按鈕時,我需要去viewcontroller 1或viewcontroller 2取決於:label1.text < label2.text
請幫助我。
通常我創建了一個新的2個NSString的至極是1等於label1.text和另一個與label2.text,當我比較這些nsstrings,我也沒有成功。 :(我也創建了應用程序代理中的NSNumbers,這與我的標籤相同,並試圖比較nsnumber,也是nu成功。 – 2012-08-17 17:55:14
@iOSBeginer請看看更新。 – dasblinkenlight 2012-08-17 17:55:56
oo .. man ..非常感謝,我這篇文章非常有用,很有用,謝謝你,很高興。 – 2012-08-17 18:00:37