我有多個變量的方法:perfomSelector上按鈕和發送參數
-(void) showImg:(UIBarButtonItem *)sender string1:(NSString *) string2:(NSString *);
我想發送NSString
值(作爲該function
用於多個元件)。
這是我加我action
時不需要參數:
[myButton addTarget:self action:@selector(showImg) forControlEvents: UIControlEventTouchUpInside];
我試過@selector
這樣內添加參數:
[myButton performSelector @selector(showImg:string1:string2::) withObject:@"-1" withObject:@"-1"];
但是,這是行不通的。如何在@selector
內直接呼叫我的function
多個參數?
它聽起來不錯,如果我想從其他方法調用'showImg'沒有按鈕引用,我可以使用不可用的'nil'來代替'(id)發送器嗎? – vadim
是的,你可以刪除參數,並使用@選擇器(showImg)和 - (void)showImg – D25
你發佈的代碼對我來說是完美的,我所要求的是如果我想調用該方法作爲書面,但我沒有按鈕發送給發件人,只是想從其他地方調用它而不改變它,我可以做這樣的事情嗎?[self showImg:nil string1:@「32.5645」string2:@「32.35553」]; ' – vadim