我有 2 个 IBaction 来增加或减少页码,但我希望我的页码永远不会为 0 或小于 0
-(IBAction)pageNumberPlus1:(id)sender {
labelpageNumberButton.text = [NSString stringWithFormat:@"%d",[labelpageNumberButton.text intValue]+1];}
-(IBAction)pageNumberMoins1:(id)sender {
labelpageNumberButton.text = [NSString stringWithFormat:@"%d",[labelpageNumberButton.text intValue]-1];
if (labelpageNumberButton.text <= [NSString stringWithFormat:@"%d",0]) {
labelpageNumberButton.text = [NSString stringWithFormat:@"%d",1];}}
这段代码在减少时很糟糕,它给出了不好的价值