用UILabel顯示電池剩余百分數。
UIDevice *myDevice = [UIDevice currentDevice];
[myDevice setBatteryMonitoringEnabled:YES];
int i=[myDevice batteryState];
_battery.text = [NSString stringWithFormat:@"%i",i];
但是label顯示的數字 2
[myDevice batteryLevel] 才是電池百分比...