objective c - iOS UIButton Touch-Up-Inside weird behavior -
my ios application contains tableview , has today widget extension wich contains tableview. both tableviews can contain cells wich feature 2 buttons. tableviews content mode "dynamic properties" , each prototype cell has own uitableviewcell class. in cellforrowatindexpath:
create cells:
}else if (...){ static nsstring *cellidentifier_item_button = @"button_cell"; btncell *button_cell = [tableview dequeuereusablecellwithidentifier:cellidentifier_item_button forindexpath:indexpath]; button_cell.on_button.tag = indexpath.row; button_cell.off_button.tag = indexpath.row; [button_cell.on_button addtarget:self action:@selector(on_button_clicked:) forcontrolevents:uicontroleventtouchupinside]; [button_cell.off_button addtarget:self action:@selector(off_button_clicked:) forcontrolevents:uicontroleventtouchupinside]; return button_cell; }
and both targets this:
-(void)off_button_clicked:(uibutton*)sender { //some additional code here [self sendrequest:url]; }
and finally:
-(void) sendrequest:(nsstring *)ip{ nsurl *requesturl = [nsurl urlwithstring:ip]; nsurlrequest *request = [nsurlrequest requestwithurl:requesturl cachepolicy:nsurlrequestreloadignoringlocalandremotecachedata timeoutinterval:10.0]; nsurlconnection *conn = [[nsurlconnection alloc] initwithrequest:request delegate:self startimmediately:yes]; }
both widget , app use exact same code. , problem: when tap on button on widget, gehts highlighted , request gets send. in app, button gets highlighted if hold button half second. have no idea why happens, ideas ? thanks
nsurlconnection *conn = [[nsurlconnection alloc] initwithrequest:request delegate:self startimmediately:yes];
will create synchronous request instead use
[nsurlconnection sendasynchronousrequest:request];
Comments
Post a Comment