objective c - how to change the textfield value when the button is clicked in uitableviewcell iOS -


i'm developing shopping app, in i'm implementing shopping cart. in app, need increase product quantity when plus button clicked , reduce product quantity when minus button clicked. here problem is, when click plus button, text field value changing in tableviewcell. me,below plus button action method

-(ibaction)plusbtn:(uibutton*)plus {     [self.tbleview beginupdates];      uitableviewcell *clickedcell = (uitableviewcell *)[[plus superview] superview];     nsindexpath *clickedbuttonindexpath = [self.tbleview indexpathforcell:clickedcell];      plus.tag = clickedbuttonindexpath.row;     quantity.tag = clickedbuttonindexpath.row;      _curr =_curr+1;     quantity.text = [nsstring stringwithformat:@"%d",_curr];      [self.tbleview endupdates];     [self.tbleview reloaddata]; } 

like

enter image description here

getting..

enter image description here

can u check functionality. useful you. hope it.

- (void)viewdidload {      [super viewdidload];       quantity =[nsmutablearray new];      occu_list = [[nsarray alloc] initwithobjects:@"occupation", @"two", @"three", @"four", @"five", @"six", @"seven", @"eight", nil];      for(int i=0;i<[occu_list count];i++)      {          [quantity addobject:@"0"];      }      click_textview=[[uiview alloc]init];      click_textview.frame=self.view.frame;      [self.view addsubview:click_textview];      [self tableviewone]; }  -(void)tableviewone {     tbl_view = [[uitableview alloc] initwithframe:self.view.frame style:uitableviewstyleplain];     tbl_view.delegate = self;     tbl_view.datasource = self;     tbl_view.backgroundcolor = [uicolor whitecolor];     tbl_view.layer.bordercolor=[[uicolor orangecolor]cgcolor];     tbl_view.layer.borderwidth=2.0f;     tbl_view.layer.cornerradius=5.0f;     tbl_view.layer.maskstobounds=yes;     [click_textview addsubview:tbl_view]; }  -(ibaction)check_btn_action:(id)sender {     uibutton *btntag=(uibutton*)sender;      nslog(@"%li",(long)btntag.tag);     nslog(@"%@",[quantity objectatindex:btntag.tag]);     int ad=[[quantity objectatindex:btntag.tag]integervalue];     ad=ad+1;    [quantity removeobjectatindex:btntag.tag];    [quantity insertobject:[nsstring stringwithformat:@"%i",ad] atindex:btntag.tag];    [tbl_view reloaddata]; } 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -