我对iOS开发很陌生。
我在标签栏控制器的视图之间传递数据时遇到问题。
ViewController // First tab in the tab bar with a number pad for entering numbers into a label
SongController // Second tab embed within a Navigation Controller searches database for number entered in the first tab and displays lyrics in a web view
我试图将 ViewController 中标签的值传递给我的 SongController 中的方法。
在ViewController.m
- (IBAction)goButton:(id)sender {
int songNum = [self.numberLabel.text intValue];
NSString *songNumber = [NSString stringWithFormat:@"%d",songNum];
if ([songNumber isEqual: @"0"] || [songNumber isEqual: @""]) {
[self.numberLabel setText:@""];
UIAlertView *songNotFound = [[UIAlertView alloc]
initWithTitle: @"Sorry"
message: @"This song could not be found."
delegate: nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[songNotFound show];
}
else
{
NSLog(@"%@", songNumber);
SongController *sing = [[SongController alloc]init];
sing.songNumberFromChooser = songNumber;
self.tabBarController.selectedIndex = 1;
}
songFromNumberChooser
中的 NSStringSongController
没有被更改。我究竟做错了什么?