无论如何在Swift中进行子类化时重写内部框架方法?防爆.超
public class BarChartRenderer: ChartDataRendererBase {
internal func drawDataSet(context context: CGContext, dataSet: BarChartDataSet, index: Int) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
我想覆盖此方法以不同的方式绘制dataSet(iOS-Charts)
public class ESBarChartRenderer: BarChartRenderer {
overide func drawDataSet(context context: CGContext, dataSet: BarChartDataSet, index: Int) {
...
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我试图覆盖Xcode时给了我错误:
方法不会覆盖其超类中的任何方法
因为它是内部的.
还有一个内部变量,我需要访问和上面相同Xcode无法看到它.
我想创建一个程序,它将从adressbook导入联系人并在tableview中显示它们.我已经完成了从adressbook下载联系人的代码,但是当我将它们添加到Array中然后尝试在TableView中显示时,它们就不会在我启动应用程序时出现.这是代码:
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[self getPersonOutOfAddressBook];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.tableData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Identifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
Person *person = [self.tableData objectAtIndex:indexPath.row];
cell.textLabel.text = person.fullName;
return cell;
}
- (void)tableView:(UITableView *)tableView …Run Code Online (Sandbox Code Playgroud) 获取我当前位置的问题.我仍然得到错误:
Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
Run Code Online (Sandbox Code Playgroud)
我已经完成了我在这里找到的所有内容:
重置iOS模拟器中的内容和设置(模拟器中的地图应用程序显示正确的位置).
在Xcode中的产品>方案>编辑我没有标记允许位置模拟(当我标记它时,它模拟例如伦敦).
我已将NSLocationWhenInUseUsageDescription添加到我项目中的Info.plist文件中(App要求获取位置权限,我可以在iOS模拟器的"设置"中看到它们).
我打开了Wi-Fi连接(就像我说的定位服务在Safari,地图甚至iOS模拟器中的地图中工作正常).
-(void)viewDidLoad {
[super viewDidLoad];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
if(IS_OS_8_OR_LATER){
NSUInteger code = [CLLocationManager authorizationStatus];
if (code == kCLAuthorizationStatusNotDetermined && ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])) {
if([[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]) {
[self.locationManager requestWhenInUseAuthorization];
} else {
NSLog(@"Info.plist does not contain NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription");
}
}
}
[self.locationManager startUpdatingLocation];
[self.FirstMap setShowsUserLocation:YES]; }
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
NSLog(@"didFailWithError: %@", error);
UIAlertView *errorAlert = [[UIAlertView …Run Code Online (Sandbox Code Playgroud) ios ×2
objective-c ×2
internal ×1
ios-charts ×1
location ×1
overriding ×1
subclassing ×1
swift ×1
tableview ×1