简体   繁体   English

请帮我!! 谁能教我IBAction如何仅在单元格上从TableView对ISArray对象使用isEqualToString?

[英]Please Help me!! Would anyone can teach me IBAction how to use `isEqualToString` to an `NSArray` object from TableView only on cell?

Anyone can teach me IBAction how to use isEqualToString to an NSArray object from a TableView with one cell? 任何人都可以教我IBAction如何在一个单元格的TableView isEqualToString用作NSArray对象?

My first page is a TableViewController with 1 Cell and I have created NSSArray object to push the data to second page ViewController. 我的第一页是一个带有1个单元格的TableViewController,我创建了NSSArray对象以将数据推送到第二页ViewController。

I created an IBAction to play a sound whenever user touch the button in ViewController. 我创建了一个IBAction来在用户触摸ViewController中的按钮时播放声音。 (It means that When I click on button it loads a sound and according to the data of Cell from NSArray) (这意味着当我单击按钮时,它会加载声音并根据NSArray中的Cell数据进行加载)

"DetailModal" is an NSArray object from other TableViewController. “ DetailModal”是其他TableViewController的NSArray对象。

I'm using AudioToolbox and I have created the sound file to soundID 我正在使用AudioToolbox,并且已将声音文件创建为soundID

How can I use isEqualToString to link the NSArray object? 如何使用isEqualToString链接NSArray对象?

For example: 例如:

I have created a list of soundID like this: 我已经创建了一个soundID列表,如下所示:

NSURL *buttonURL1 = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"A" ofType:@"m4a"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)buttonURL1, &soundID1);

NSURL *buttonURL2 = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"I" ofType:@"m4a"]];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)buttonURL2, &soundID2);

and

Detail2ViewController.h Detail2ViewController.h

@property (strong, nonatomic) NSArray *DetailModal;

How can I use "isEqualToString" to a NSArray object in IBAction? 如何在IBAction中对NSArray对象使用“ isEqualToString”?

- (IBAction)Sound {

    int sound =  _DetailModal;  (Don't know how to do. Want to equal a object _DetailModal but show error)

    if ([_TitleLabel.text isEqualToString:@"/a/"]) {    (_TitleLabel is a NSSArray object and equal to _DetailModal from another TableViewController)
        AudioServicesPlaySystemSound(soundID1);
    }

    if ([_TitleLabel.text isEqualToString:@"/i/"]) {
        AudioServicesPlaySystemSound(soundID2);
    }
}

I have tried but fail... 我已经尝试过但是失败了...

I'm using storyboard 我正在使用情节提要

Thanks for advance! 感谢前进! (I'm really beginner) (我真的是初学者)

What I understand from your question is that you have problem in passing data from one controller to another controller ie from tableviewcontroller to detailview in your case. 我从您的问题中了解到,在您的情况下,您无法将数据从一个控制器传递到另一个控制器,即从tableviewcontroller传递到detailview。

You can use following method in storyboard: 您可以在情节提要中使用以下方法:

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender (void)prepareForSegue:(UIStoryboardSegue *)segue发送者:(id)sender

Please refer: http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2 请参阅: http : //www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2

Modify your condition like that in IBAction for checking isEqualToString inside NSArray :- 像在IBAction那样修改条件,以检查NSArray内的isEqualToString :-

for (NSString *str in _TitleLabel)
{
if([str isEqualToString:@"/a/"])
{
//Write your code
}
if ([str isEqualToString:@"/i/"]) 
{
//Write your code
}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 谁能帮我拆卸EXPO应用程序 - Can anyone help me to detach expo app 谁能帮我解决这个xcode问题? - Can anyone help me with this xcode issue? 在创建tableView的Custom CellView之后,我仍然没有获得多列视图。 谁能帮我吗? - After creating a Custom CellView of a tableView, still i am not getting the multiple column view. Can anyone help me out? 谁能告诉我为什么滚动之前不显示tableview数据? - Can anyone tell me why tableview data are not displaying until scroll? 谁能帮我这个? 我无法理解这个 - can anyone help me with this ? I can't understand this 谁能帮助我设置Salesforce Mobile SDK for iOS? - Can anyone help me setting up the Salesforce Mobile SDK for iOS? Flutter 应用程序无法与 android 工作室一起运行任何人都可以帮助我吗? - Flutter app not run with android studio can anyone help me out? 有人可以帮我修复这个 Xcode 的 UICollection 吗? - Can someone please help me fix this Xcode for a UICollection? 我在我的应用中遇到了NSInvalidArgumentException错误……任何擅长此操作的人都请帮助我 - i Got NSInvalidArgumentException error in my app… anyone good at this please help me 帮助我从json订阅源获取每个元素? 请 - help me to get each elements from my json feed ? Please
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM